本文整理汇总了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());
}
}