mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Реализована логика oAuth авторизации приложений, добавлен Redis, удалены лишние тесты, пофикшены старые.
This commit is contained in:
49
common/models/OauthClient.php
Normal file
49
common/models/OauthClient.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* Поля модели:
|
||||
* @property string $id
|
||||
* @property string $secret
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property string $redirect_uri
|
||||
* @property integer $account_id
|
||||
* @property bool $is_trusted
|
||||
* @property integer $created_at
|
||||
*
|
||||
* Отношения:
|
||||
* @property Account $account
|
||||
* @property OauthSession[] $sessions
|
||||
*/
|
||||
class OauthClient extends ActiveRecord {
|
||||
|
||||
public static function tableName() {
|
||||
return '{{%oauth_clients}}';
|
||||
}
|
||||
|
||||
public function rules() {
|
||||
return [
|
||||
[['id'], 'required', 'when' => function(self $model) {
|
||||
return $model->isNewRecord;
|
||||
}],
|
||||
[['id'], 'unique', 'when' => function(self $model) {
|
||||
return $model->isNewRecord;
|
||||
}],
|
||||
[['name', 'description'], 'required'],
|
||||
[['name', 'description'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
public function getAccount() {
|
||||
return $this->hasOne(Account::class, ['id' => 'account_id']);
|
||||
}
|
||||
|
||||
public function getSessions() {
|
||||
return $this->hasMany(OauthSession::class, ['client_id' => 'id']);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user