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


PHP User::findIdentityByAccessToken方法代碼示例

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


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

示例1: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findIdentityByAccessToken($this->username);
     }
     return $this->_user;
 }
開發者ID:JohnRivers,項目名稱:seed-testing,代碼行數:12,代碼來源:LoginForm.php

示例2: checkAccess

 public function checkAccess($action, $model = null, $params = [])
 {
     if (User::findIdentityByAccessToken($_GET['access_token'])->id == 1) {
         $isAdmin = true;
     } else {
         $isAdmin = false;
     }
     if (!$isAdmin || Yii::$app->user->isGuest) {
         throw new \yii\web\ForbiddenHttpException("You can't access this page.");
     }
 }
開發者ID:fosker,項目名稱:dbm,代碼行數:11,代碼來源:UserController.php

示例3: testFindUserByAccessToken

 public function testFindUserByAccessToken()
 {
     expect_that($user = User::findIdentityByAccessToken('neo'));
     expect($user->username)->equals('neo');
     expect_not(User::findIdentityByAccessToken('non-existing'));
 }
開發者ID:amnah,項目名稱:yii2-angular,代碼行數:6,代碼來源:User1Test.php

示例4: actionChangesecurity

 /**
  * Let user to change password authentication by given access token
  * @param string $token Access Token
  * @return type mixed
  */
 public function actionChangesecurity($token)
 {
     //if user exists
     if ($model = User::findIdentityByAccessToken(base64_decode($token))) {
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             $model->access_token = Yii::$app->security->generateRandomString(64);
             $model->save();
             Yii::$app->session->setFlash('success', 'Please login with updated password!');
             $this->redirect('login');
         }
         unset($model->password);
         return $this->render('changepassword', ['model' => $model]);
     } else {
         throw new ForbiddenHttpException('You are not allowed to perform this action.');
     }
 }
開發者ID:livingdreams,項目名稱:kidcrossing,代碼行數:21,代碼來源:AdminController.php

示例5: loginByAccessToken

 public function loginByAccessToken($token, $type = null)
 {
     $identity = User::findIdentityByAccessToken($token, $type);
     if ($identity && $this->login($identity)) {
         return $identity;
     } else {
         return null;
     }
 }
開發者ID:ercling,項目名稱:auth,代碼行數:9,代碼來源:UserManager.php

示例6: generateDoc

 /**
  * generate doc
  * @var array $params
  */
 public function generateDoc($params)
 {
     Yii::$app->user->identity = \app\models\User::findIdentityByAccessToken($params['template']['key']);
     header("Content-Description: File Transfer");
     header('Content-Transfer-Encoding: binary');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Expires: 0');
     switch ($params['template']['format']) {
         case 'PDF':
             $file = Yii::$app->user->id . '_temp.pdf';
             $writeFormat = 'PDF';
             PhpWordSettings::setPdfRendererPath(dirname(__DIR__) . '/../../../vendor/tecnickcom/tcpdf');
             PhpWordSettings::setPdfRendererName('TCPDF');
             header('Content-Type: application/pdf');
             break;
         case 'Word2013':
             $file = Yii::$app->user->id . '_temp.docx';
             $writeFormat = 'Word2013';
             header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
             break;
         default:
             $file = Yii::$app->user->id . '_temp.doc';
             $writeFormat = 'Word2007';
             header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
             break;
     }
     header('Content-Disposition: attachment; filename="' . $file . '"');
     $document = new TemplateProcessor(dirname(__DIR__) . '/../../../files/' . $this->id . '/' . $this->template_file);
     /**
      * process the fields, that have been send through the rest interface
      */
     foreach ($params['template']['fields'] as $field) {
         foreach ($field as $key => $value) {
             $document->setValue($key, UTF8encoding::fixUTF8($value));
         }
     }
     /**
      * process the tables, that have been send through the rest interface
      */
     foreach ($params['template']['tables'] as $tables) {
         foreach ($tables as $name => $rows) {
             //first we create a clone for the master row
             $document->cloneRow($name, count($rows));
             //our walking variable for the table
             $ii = 1;
             foreach ($rows as $row) {
                 foreach ($row as $cell) {
                     $document->setValue(key($cell) . '#' . $ii, current($cell));
                 }
                 $ii++;
             }
         }
     }
     // save as a random file in temp file
     $temp_file = tempnam(sys_get_temp_dir(), $file);
     $document->saveAs($temp_file);
     switch ($params['template']['format']) {
         case 'PDF':
             $phpWord = IOFactory::load($temp_file);
             $xmlWriter = IOFactory::createWriter($phpWord, $writeFormat);
             $xmlWriter->save("php://output");
             break;
         case 'Word2007':
             $phpWord = IOFactory::load($temp_file);
             $xmlWriter = IOFactory::createWriter($phpWord, $writeFormat);
             $xmlWriter->save("php://output");
             break;
         default:
             readfile($temp_file);
             break;
     }
     unlink($temp_file);
     $LogEvent = new TemplateEvent();
     $LogEvent->aTemplateCreated(Yii::$app->user->identity->username, $this->id);
     \Yii::$app->end();
 }
開發者ID:philippfrenzel,項目名稱:wortundtat,代碼行數:80,代碼來源:Template.php

示例7: actionTest

 public function actionTest()
 {
     return US::findIdentityByAccessToken('4f39779fd6acb266333ad658c317deb2390a8fde231447e2d8ae41079ff0a936');
 }
開發者ID:MaoCzedun,項目名稱:AdCoin,代碼行數:4,代碼來源:RestController.php

示例8: testFindIdentityByAccessToken

 /**
  * @expectedException Exception
  * @expectedExceptionMessage findIdentityByAccessToken is not implemented.
  */
 public function testFindIdentityByAccessToken()
 {
     expect_not(User::findIdentityByAccessToken('test_token'));
 }
開發者ID:rkit,項目名稱:bootstrap-yii2,代碼行數:8,代碼來源:UserTest.php


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