Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active January 5, 2017 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/3a68130a86cca5607596 to your computer and use it in GitHub Desktop.
Save kurozumi/3a68130a86cca5607596 to your computer and use it in GitHub Desktop.
【EC-CUBE2.13】ユーザーがcustomer_idでログインできるようにする方法
<?php
require_once CLASS_REALDIR . 'SC_Customer.php';
class SC_Customer_Ex extends SC_Customer
{
/**
* ログインemailを取得する
*
* @param type $login_email
* @return boolean
*/
public function getEmail($login_email)
{
$objQuery =& SC_Query_Ex::getSingletonInstance();
$cols = 'email';
$table = 'dtb_customer';
$where = 'customer_id = ? AND del_flg = 0 AND status = 2';
$arrData = $objQuery->getRow($cols, $table, $where, array($login_email));
if (SC_Utils_Ex::isBlank($arrData) === false) {
return $arrData['email'];
}else{
$where = 'email = ? AND del_flg = 0 AND status = 2';
$arrData = $objQuery->getRow($cols, $table, $where, array($login_email));
if (SC_Utils_Ex::isBlank($arrData) === fase)
return $arrData['email'];
}
return false;
}
/**
* ログインを実行する.
*
* ログインを実行し, 成功した場合はユーザー情報をセッションに格納し,
* true を返す.
* モバイル端末の場合は, 携帯端末IDを保存する.
* ログインに失敗した場合は, false を返す.
*
* @param string $login_email ログインメールアドレス
* @param string $login_pass ログインパスワード
* @return boolean|null ログインに成功した場合 true; 失敗した場合 false
*/
public function doLogin($login_email, $login_pass)
{
switch (SC_Display_Ex::detectDevice()) {
case DEVICE_TYPE_MOBILE:
if (!$this->getCustomerDataFromMobilePhoneIdPass($login_pass) &&
!$this->getCustomerDataFromEmailPass($login_pass, $login_email, true)
) {
return false;
} else {
// Session Fixation対策
SC_Session_Ex::regenerateSID();
$this->updateMobilePhoneId();
return true;
}
break;
case DEVICE_TYPE_SMARTPHONE:
case DEVICE_TYPE_PC:
default:
// emailが取得できなかったらログインできない
if(!($login_email = $this->getEmail($login_email)))
return false;
if (!$this->getCustomerDataFromEmailPass($login_pass, $login_email)) {
return false;
} else {
// Session Fixation対策
SC_Session_Ex::regenerateSID();
return true;
}
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment