當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserIdentity::registAuth方法代碼示例

本文整理匯總了PHP中UserIdentity::registAuth方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserIdentity::registAuth方法的具體用法?PHP UserIdentity::registAuth怎麽用?PHP UserIdentity::registAuth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserIdentity的用法示例。


在下文中一共展示了UserIdentity::registAuth方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 public function run()
 {
     if (Yii::app()->request->isAjaxRequest) {
         try {
             $name = Yii::app()->request->getParam('name');
             $mobile = Yii::app()->request->getParam('mobile');
             $code = Yii::app()->request->getParam('code');
             $email = Yii::app()->request->getParam('email');
             $password = Yii::app()->request->getParam('password');
             $actcode = Yii::app()->request->getParam('actcode');
             $_code = Yii::app()->session['regist_code' . $mobile];
             if ($_code && $_code == $code) {
                 $item = Yii::app()->db->createCommand('select * from user where mobile=' . $mobile . ' and status=0')->queryRow();
                 if (!$item) {
                     $user = new User();
                     $user->nickName = $name;
                     $user->mobile = $mobile;
                     $user->email = $email;
                     $user->status = 4;
                     if ($password) {
                         $user->password = md5($password);
                     }
                     $wechat = Yii::app()->session['wechat'];
                     if ($wechat) {
                         // $user->nickName = $wechat['nickname'];
                         $user->portrait = $wechat['headimgurl'];
                         $user->gender = $wechat['sex'];
                     }
                     //邀請人公司賦值
                     $codedetail = Code::model()->findByAttributes(array('code' => $actcode));
                     $companyId = User::model()->findByAttributes(array('id' => $codedetail->userId))->company;
                     $user->company = $companyId;
                     $user->insert();
                     //消息係統初始化
                     EasemobHelper::initIM($user->id, array('username' => $user->id, 'password' => 'nakedim', 'nickname' => $name));
                     $user->type = 2;
                     $user->isBindIM = 1;
                     $user->save();
                     $codedetail->times--;
                     $codedetail->save();
                     $codeused = new CodeUsed();
                     $codeused->codeId = $codedetail->id;
                     $codeused->userId = $user->id;
                     $codeused->createTime = date("Y-m-d");
                     $codeused->save();
                     Yii::app()->session['user'] = $user;
                 } else {
                     Yii::log(print_r($item, 1), CLogger::LEVEL_ERROR, 'info');
                     Yii::app()->session['user'] = $item;
                 }
                 //如果用戶注冊過了,沒付款不生成新的用戶,讀取數據庫裏的用戶信息
                 $identity = new UserIdentity();
                 $identity->registAuth($user);
                 $duration = Yii::app()->getComponent('session')->getTimeout();
                 Yii::app()->user->login($identity, $duration);
                 echo CJSON::encode(array('code' => 200, 'message' => 'success'));
             } else {
                 echo CJSON::encode(array('code' => 500, 'message' => '驗證碼錯誤'));
             }
         } catch (CException $e) {
             Yii::log($e->getMessage(), CLogger::LEVEL_ERROR);
             echo CJSON::encode(array('code' => 500, 'message' => '注冊失敗'));
         }
     }
 }
開發者ID:itliuchang,項目名稱:test,代碼行數:65,代碼來源:CodeRegistAction.php

示例2: run

 public function run()
 {
     if (Yii::app()->user->isGuest) {
         $user = Yii::app()->session['user'];
         $identity = new UserIdentity($user);
         $identity->registAuth($user);
         $duration = Yii::app()->getComponent('session')->getTimeout();
         Yii::app()->user->login($identity, $duration);
         // Yii::log(print_r($user,1), CLogger::LEVEL_ERROR,'222');
         $tuser = User::model()->findByAttributes(array('id' => $user['id']));
         $tuser->status = 1;
         $tuser->save();
         $this->controller->redirect('/user/updateProfile');
     } else {
         $tem = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
         $status = $tem->status;
         $type = $tem->type;
         if ($type == 1) {
             switch ($status) {
                 case 1:
                     $this->controller->redirect('/user/updateProfile');
                     break;
                 default:
                     $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
                     Yii::app()->user->setState('portrait', $user->portrait);
                     $this->controller->redirect(Assist::getDefaultURL());
                     break;
             }
         } else {
             if ($type == 2) {
                 switch ($status) {
                     case 1:
                         $this->controller->redirect('/user/updateProfile');
                         break;
                     default:
                         $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
                         Yii::app()->user->setState('portrait', $user->portrait);
                         $this->controller->redirect(Assist::getDefaultURL());
                         break;
                 }
             } else {
                 if ($type == 3) {
                     switch ($status) {
                         case 1:
                             $this->controller->redirect('/user/updateProfile');
                             break;
                         case 2:
                             $this->controller->redirect('/company/updateProfile');
                             break;
                         case 3:
                             $this->controller->redirect('/registered/code');
                             break;
                         default:
                             $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
                             Yii::app()->user->setState('portrait', $user->portrait);
                             $this->controller->redirect(Assist::getDefaultURL());
                             break;
                     }
                 }
             }
         }
         // Yii::log($status, CLogger::LEVEL_ERROR,'status');
         // switch ($status) {
         // 	case 1:
         // 		$this->controller->redirect('/user/updateProfile');
         // 		break;
         // 	case 2:
         // 		$this->controller->redirect('/company/updateProfile');
         // 	case 21:
         // 		$this->controller->redirect('/user/updateProfile');
         // 	case 22:
         // 		$this->controller->redirect('/user/updatecompany');
         // 	default:
         // 		$user= User::model()->findByAttributes(array('id'=>Yii::app()->user->id));
         // 		Yii::app()->user->setState('portrait',$user->portrait);
         // 		$this->controller->redirect(Assist::getDefaultURL());
         // 		break;
         // }
     }
 }
開發者ID:itliuchang,項目名稱:test,代碼行數:80,代碼來源:AccessAction.php


注:本文中的UserIdentity::registAuth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。