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


PHP User::findIdentityByAccessToken方法代码示例

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


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

示例1: init

 public function init()
 {
     $this->registerAssets();
     parent::init();
     // If API log in is allowed AND the auth-token is provided.
     // todo refactor this, ATM a clug to get it working - DJE : 2015-07-23
     if ($this->allowAPILogin && (Yii::$app->request->get('auth-token') != false && Yii::$app->request->get('auth-token') !== null)) {
         /* Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
            $headers = Yii::$app->response->headers;
            $headers->add('Content-Type', 'application/json; charset=utf-8'); */
         // Guest user still needs session to hide header
         if (Yii::$app->request->get('auth-token') != "guest") {
             $userMDL = User::findIdentityByAccessToken(Yii::$app->request->get('auth-token'));
             // if the user was successfully logged in, return a message saying so
             if (Yii::$app->user->login($userMDL)) {
                 //$returnData = ['status' => 'success' ];
             } else {
                 //$returnData = ['status' => 'failed'];
             }
             //echo json_encode( $returnData );
         }
         Yii::$app->session->set('mobile', 'true');
         Yii::$app->response->redirect(\Yii::$app->urlManager->createAbsoluteUrl('forum'));
         Yii::$app->end();
     }
     // @depricated 2.0.0 Use the parent applications error settings
     /*
     \Yii::$app->setComponents(
         array(
             'errorHandler' => [
                 'errorAction' => 'site/error'
             ],
         )
     );
     */
     // @todo no longer needed per Yii2
     /*
     // import the module-level models and components
     $this->setImport(array(
         $this->id.'.models.*',
         $this->id.'.components.*',
     ));
     */
 }
开发者ID:sourcetoad,项目名称:bbii2,代码行数:44,代码来源:Module.php

示例2: fields

 /**
  * @inheritdoc
  */
 public function fields()
 {
     $fields = parent::fields();
     $user = User::findIdentityByAccessToken(\Yii::$app->request->get('access-token'));
     if (is_object($user) && $this->user_id == $user->user_id) {
         $fields['auth'] = function () {
             $user = $this->getUser();
             return ['stream_userid' => $user->stream_userid, 'stream_username' => $user->stream_username, 'stream_password' => $user->stream_password];
         };
     } else {
         $fields = [];
     }
     $fields['public_url'] = function () {
         $name = explode("=", $this->stream_stream);
         if (is_array($name) && count($name) === 3) {
             $file = $name[2];
             return "http://rrr.sz.xlcdn.com/?account=gtecmedia&file={$file}&type=live&service=wowza&output=player";
         }
         return null;
     };
     return $fields;
 }
开发者ID:pylypen,项目名称:api-side,代码行数:25,代码来源:Stream.php

示例3: beforeSave

 public function beforeSave($insert)
 {
     $user = User::findIdentityByAccessToken(Yii::$app->request->get('access-token'));
     $this->review_user_id = $user->user_id;
     return $this->review_rating > 0 ? true : false;
 }
开发者ID:pylypen,项目名称:api-side,代码行数:6,代码来源:Reviews.php


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