Last active
January 5, 2017 13:37
-
-
Save kurozumi/3a68130a86cca5607596 to your computer and use it in GitHub Desktop.
【EC-CUBE2.13】ユーザーがcustomer_idでログインできるようにする方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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