當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。