当前位置: 首页>>代码示例>>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;未经允许,请勿转载。