本文整理匯總了PHP中UserIdentity::authMobile方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserIdentity::authMobile方法的具體用法?PHP UserIdentity::authMobile怎麽用?PHP UserIdentity::authMobile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserIdentity
的用法示例。
在下文中一共展示了UserIdentity::authMobile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
public function run()
{
$this->controller->pageTitle = 'Login';
if (Yii::app()->user->isGuest) {
if (Yii::app()->request->isAjaxRequest) {
$mobile = Yii::app()->request->getParam('mobile');
$code = Yii::app()->request->getParam('code');
$email = Yii::app()->request->getParam('email');
$password = Yii::app()->request->getParam('password');
$bind = Yii::app()->request->getParam('bind');
$_identity = new UserIdentity();
if ($mobile) {
Yii::log($code, CLogger::LEVEL_ERROR);
$_identity->authMobile($mobile, $code, $bind);
if ($_identity->errorCode === UserIdentity::ERROR_NONE) {
$duration = 86400;
Yii::app()->user->login($_identity, $duration);
echo CJSON::encode(array('code' => 200, 'message' => 'success'));
//$this->controller->redirect(Yii::app()->user->getReturnUrl(Assist::getDefaultURL()));
} elseif ($_identity->errorCode === UserIdentity::ERROR_CODE_INVALID) {
echo CJSON::encode(array('code' => 500, 'message' => '驗證碼不正確'));
} elseif ($_identity->errorCode === UserIdentity::ERROR_MOBILE_INVALID) {
echo CJSON::encode(array('code' => 500, 'message' => '手機號未注冊'));
} else {
echo CJSON::encode(array('code' => 500, 'message' => '登錄錯誤'));
}
} elseif ($email) {
$_identity->authMail($email, $password, $bind);
if ($_identity->errorCode === UserIdentity::ERROR_NONE) {
$duration = 86400;
Yii::app()->user->login($_identity, $duration);
echo CJSON::encode(array('code' => 200, 'message' => 'success'));
//$this->controller->redirect(Assist::getDefaultURL());
//$this->controller->redirect(Yii::app()->user->getReturnUrl(Assist::getDefaultURL()));
} elseif ($_identity->errorCode === UserIdentity::ERROR_MAIL_INVALID) {
echo CJSON::encode(array('code' => 500, 'message' => '郵箱未注冊'));
} elseif ($_identity->errorCode === UserIdentity::ERROR_PASSWORD_INVALID) {
echo CJSON::encode(array('code' => 500, 'message' => '密碼錯誤'));
} else {
echo CJSON::encode(array('code' => 500, 'message' => '登錄錯誤'));
}
} else {
throw new CHttpException('405', '參數錯誤');
}
} else {
$this->controller->render('login');
}
} else {
$this->controller->redirect(Assist::getAccessURL());
}
}