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 | 5 | $type = null |
|
16 | 5 | ): ?static { |
|
|
|||
17 | 5 | return static::find()->innerJoinWith([ |
|
18 | 5 | 'activeAccessToken' => function (ActiveQuery $query) use ($token) { |
|
19 | 5 | $query->andWhere(['access_token' => $token]); |
|
20 | }, |
||
21 | ])->one(); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | 5 | * @return ActiveQuery |
|
26 | */ |
||
27 | 5 | public function getAccessTokens(): ActiveQuery |
|
28 | { |
||
29 | return $this->hasMany(AccessToken::class, ['user_id' => 'id']); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | 5 | * @return ActiveQuery |
|
34 | */ |
||
35 | 5 | public function getActiveAccessToken(): ActiveQuery |
|
36 | 5 | { |
|
37 | $query = $this->getAccessTokens(); |
||
38 | 5 | $query->multiple = false; |
|
39 | |||
40 | return $query; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | 1 | * @inheritdoc |
|
45 | */ |
||
46 | 1 | public function getAccessTokenData(): AccessToken |
|
47 | { |
||
48 | return $this->activeAccessToken; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | 1 | * @inheritdoc |
|
53 | */ |
||
54 | 1 | public function revokeActiveAccessToken(): bool |
|
55 | { |
||
56 | return $this->getAccessTokenData()->delete(); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @inheritdoc |
||
61 | */ |
||
62 | public function revokeAllAccessTokens(): bool |
||
63 | { |
||
68 |