1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace roaresearch\yii2\oauth2server\models; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
use yii\db\{ActiveQuery, ActiveRecord}; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* This is the model class for table "oauth_authorization_codes". |
10
|
|
|
* |
11
|
|
|
* @property string $authorization_code |
12
|
|
|
* @property string $client_id |
13
|
|
|
* @property integer $user_id |
14
|
|
|
* @property string $redirect_uri |
15
|
|
|
* @property string $expires |
16
|
|
|
* @property string $scope |
17
|
|
|
* |
18
|
|
|
* @property OauthClients $client |
19
|
|
|
*/ |
20
|
|
|
class OauthAuthorizationCodes extends ActiveRecord |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @inheritdoc |
24
|
|
|
*/ |
25
|
|
|
public static function tableName(): string |
26
|
|
|
{ |
27
|
|
|
return '{{%oauth_authorization_codes}}'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @inheritdoc |
32
|
|
|
*/ |
33
|
|
|
public function rules(): array |
34
|
|
|
{ |
35
|
|
|
return [ |
36
|
|
|
[ |
37
|
|
|
['authorization_code', 'client_id', 'redirect_uri', 'expires'], |
38
|
|
|
'required', |
39
|
|
|
], |
40
|
|
|
[['user_id'], 'integer'], |
41
|
|
|
[['expires'], 'safe'], |
42
|
|
|
[['authorization_code'], 'string', 'max' => 40], |
43
|
|
|
[['client_id'], 'string', 'max' => 32], |
44
|
|
|
[['redirect_uri'], 'string', 'max' => 1000], |
45
|
|
|
[['scope'], 'string', 'max' => 2000] |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @inheritdoc |
51
|
|
|
*/ |
52
|
|
|
public function attributeLabels(): array |
53
|
|
|
{ |
54
|
|
|
return [ |
55
|
|
|
'authorization_code' => 'Authorization Code', |
56
|
|
|
'client_id' => 'Client ID', |
57
|
|
|
'user_id' => 'User ID', |
58
|
|
|
'redirect_uri' => 'Redirect Uri', |
59
|
|
|
'expires' => 'Expires', |
60
|
|
|
'scope' => 'Scope', |
61
|
|
|
]; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return ActiveQuery |
66
|
|
|
*/ |
67
|
|
|
public function getClient(): ActiveQuery |
68
|
|
|
{ |
69
|
|
|
return $this->hasOne(OauthClients::class, ['client_id' => 'client_id']); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|