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


PHP UserIdentity::createAuthenticatedIdentity方法代码示例

本文整理汇总了PHP中UserIdentity::createAuthenticatedIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP UserIdentity::createAuthenticatedIdentity方法的具体用法?PHP UserIdentity::createAuthenticatedIdentity怎么用?PHP UserIdentity::createAuthenticatedIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserIdentity的用法示例。


在下文中一共展示了UserIdentity::createAuthenticatedIdentity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 public function actionIndex()
 {
     $user = new User();
     if (!empty($_POST['User'])) {
         $user->attributes = $_POST['User'];
         if ($user->save()) {
             Yii::app()->user->login(UserIdentity::createAuthenticatedIdentity($user->username, $user->id), 0);
             echo json_encode(array('errors' => ''));
         } else {
             $errors = $user->getErrors();
             echo json_encode(array('errors' => $errors));
         }
         exit;
     }
     $this->render('index', array('model' => $user));
 }
开发者ID:limmer3,项目名称:instagress,代码行数:16,代码来源:RegisterController.php

示例2: actionSuccess

 /**
  * running when login success
  */
 public function actionSuccess()
 {
     $instagram = Yii::app()->instagram;
     // receive OAuth code parameter
     $code = $_GET['code'];
     // check whether the user has granted access
     if (isset($code)) {
         // receive OAuth token object
         $data = $instagram->getOAuthToken($code);
         $username = $data->user->username;
         $user_id = $data->user->id;
         $avatar = $data->user->profile_picture;
         // store user access token
         $instagram->setAccessToken($data);
         // now you have access to all authenticated user methods
         $result = $instagram->getUserMedia();
         if ($data) {
             // save this information to db
             $user = new User('instagram_login');
             $user->username = $username;
             $user->instagram_id = $data->user->id;
             $user->access_token = $instagram->getAccessToken($data);
             $user->full_name = $data->user->full_name;
             $user->avatar = $avatar;
             // check if instagram_id is unique then save to db
             $user = $user->zeroUnique();
             if (!isset(Yii::app()->user->id)) {
                 // login automatically
                 Yii::app()->user->login(UserIdentity::createAuthenticatedIdentity($user->username, $user->id), 0);
                 $this->redirect('/user/activity');
             }
             $this->redirect('/user/account');
         } else {
             throw new CHttpException('There are some issues with login on instagram.');
         }
     } else {
         // check whether an error occurred
         if (isset($_GET['error'])) {
             echo 'An error occurred: ' . $_GET['error_description'];
         }
     }
     $this->render('success', array('result' => $result, 'username' => $username));
 }
开发者ID:rishabhthakur,项目名称:instagress,代码行数:46,代码来源:SiteController.php

示例3: actionActivate

 public function actionActivate($a)
 {
     if ($a != '') {
         $model = User::model()->find('activate=:a', array(':a' => $a));
         d2l($model->attributes);
         if ($model) {
             //		    /$model->activate='';
             if ($model->status != User::STATUS_ACTIVE) {
                 $model->status = User::STATUS_ACTIVE;
                 if ($model->update(array('status'))) {
                     Yii::app()->user->login(UserIdentity::createAuthenticatedIdentity($model->username, $model->id), 0);
                     d2l(Yii::app()->user->model->attributes);
                     $this->render('activate', array('model' => $model, 'status' => 'success'));
                 }
             } else {
                 Yii::app()->user->logout();
                 $this->render('activate', array('model' => $model, 'status' => 'already'));
             }
         } else {
             throw new CHttpException(404, "Invalid Activation Code!");
         }
     }
 }
开发者ID:videocms,项目名称:videocms-test,代码行数:23,代码来源:AdminController.php


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