Total Complexity | 6 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Coverage | 88.89% |
Changes | 0 |
1 | <?php |
||
8 | trait RevokeAccessTokenTrait |
||
9 | { |
||
10 | /** |
||
11 | * @inheritdoc |
||
12 | */ |
||
13 | 5 | public static function findIdentityByAccessToken( |
|
14 | $token, |
||
15 | $type = null |
||
16 | ): ?static { |
||
|
|||
17 | 5 | return static::find()->innerJoinWith([ |
|
18 | 5 | 'activeAccessToken' => function (ActiveQuery $query) use ($token) { |
|
19 | 5 | $query->andWhere(['access_token' => $token]); |
|
20 | }, |
||
21 | 5 | ])->one(); |
|
22 | } |
||
23 | |||
24 | /** |
||
25 | * @return ActiveQuery |
||
26 | */ |
||
27 | 5 | public function getAccessTokens(): ActiveQuery |
|
28 | { |
||
29 | 5 | return $this->hasMany(AccessToken::class, ['user_id' => 'id']); |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * @return ActiveQuery |
||
34 | */ |
||
35 | 5 | public function getActiveAccessToken(): ActiveQuery |
|
36 | { |
||
37 | 5 | $query = $this->getAccessTokens(); |
|
38 | 5 | $query->multiple = false; |
|
39 | |||
40 | 5 | return $query; |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * @inheritdoc |
||
45 | */ |
||
46 | 1 | public function getAccessTokenData(): AccessToken |
|
47 | { |
||
48 | 1 | return $this->activeAccessToken; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | */ |
||
54 | 1 | public function revokeActiveAccessToken(): bool |
|
55 | { |
||
56 | 1 | return $this->getAccessTokenData()->delete(); |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @inheritdoc |
||
61 | */ |
||
62 | public function revokeAllAccessTokens(): bool |
||
63 | { |
||
68 |