コード例 #1
0
ファイル: User.php プロジェクト: defektrain/sgm-rest
 /**
  * @inheritdoc
  */
 public static function findIdentityByAccessToken($token, $type = null)
 {
     $oauthToken = OauthAccessTokens::findOne(['access_token' => $token]);
     if ($oauthToken) {
         return static::findOne(['id' => $oauthToken->user_id]);
     }
     //        throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
 }
コード例 #2
0
 /**
  * @inheritdoc
  */
 public static function findIdentityByAccessToken($token, $type = null)
 {
     // Get token
     $oauthToken = OauthAccessTokens::find()->andWhere('expires > NOW()')->andWhere(['access_token' => $token])->one();
     if (!$oauthToken) {
         return null;
     }
     return User::findOne($oauthToken->user_id);
 }
コード例 #3
0
 public function actionRevoke()
 {
     if (Yii::$app->user->logout()) {
         $token = OauthAccessTokens::find()->where(['access_token' => $this->accessToken])->one();
         if ($token) {
             $token->expires = new \yii\db\Expression('NOW()');
             $token->save();
         }
         return ['success' => true];
     } else {
         Yii::$app->getResponse()->setStatusCode(500);
         return ['success' => false];
     }
 }
コード例 #4
0
ファイル: User.php プロジェクト: hiqdev/hi3a
 /**
  * @inheritdoc
  */
 public static function findIdentityByAccessToken($access_token, $type = null)
 {
     $token = OauthAccessTokens::findOne(compact('access_token'));
     return static::findByUsername($token->user_id);
 }
コード例 #5
0
ファイル: OauthController.php プロジェクト: hiqdev/hiam-core
 public function findToken($access_token)
 {
     return OauthAccessTokens::findOne($access_token);
 }
コード例 #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOauthAccessTokens()
 {
     return $this->hasMany(OauthAccessTokens::className(), ['client_id' => 'client_id']);
 }