mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Реализована логика oAuth авторизации приложений, добавлен Redis, удалены лишние тесты, пофикшены старые.
This commit is contained in:
41
common/models/OauthAccessToken.php
Normal file
41
common/models/OauthAccessToken.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace common\models;
|
||||
|
||||
use common\components\redis\Set;
|
||||
use Yii;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* This is the model class for table "oauth_access_tokens".
|
||||
*
|
||||
* @property string $access_token
|
||||
* @property string $session_id
|
||||
* @property integer $expire_time
|
||||
*
|
||||
* @property Set $scopes
|
||||
*/
|
||||
class OauthAccessToken extends ActiveRecord {
|
||||
|
||||
public static function tableName() {
|
||||
return '{{%oauth_access_tokens}}';
|
||||
}
|
||||
|
||||
public function getSession() {
|
||||
return $this->hasOne(OauthSession::class, ['id' => 'session_id']);
|
||||
}
|
||||
|
||||
public function getScopes() {
|
||||
return new Set($this->getDb()->getSchema()->getRawTableName($this->tableName()), $this->access_token, 'scopes');
|
||||
}
|
||||
|
||||
public function beforeDelete() {
|
||||
if (!$result = parent::beforeDelete()) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$this->getScopes()->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user