/** * @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); }
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]; } }