当前位置: 首页>>代码示例>>PHP>>正文


PHP UserIdentity::authMobile方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:itliuchang,项目名称:test,代码行数:51,代码来源:LoginAction.php


注:本文中的UserIdentity::authMobile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。