|
1
|
|
|
<?php namespace App\Modules\OauthClients\Services; |
|
2
|
|
|
|
|
3
|
|
|
use App\Modules\Core\BaseClasses\BaseService; |
|
4
|
|
|
use App\Modules\OauthClients\Repositories\OauthClientRepository; |
|
5
|
|
|
|
|
6
|
|
|
class OauthClientService extends BaseService |
|
7
|
|
|
{ |
|
8
|
|
|
/** |
|
9
|
|
|
* Init new object. |
|
10
|
|
|
* |
|
11
|
|
|
* @param OauthClientRepository $repo |
|
12
|
|
|
* @return void |
|
|
|
|
|
|
13
|
|
|
*/ |
|
14
|
|
|
public function __construct(OauthClientRepository $repo) |
|
15
|
|
|
{ |
|
16
|
|
|
parent::__construct($repo); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Revoke the given client. |
|
21
|
|
|
* |
|
22
|
|
|
* @param integer $clientId |
|
23
|
|
|
* @return void |
|
24
|
|
|
*/ |
|
25
|
|
|
public function revoke($clientId) |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
\DB::transaction(function () use ($data) { |
|
|
|
|
|
|
28
|
|
|
$client = $this->repo->find($clientId); |
|
|
|
|
|
|
29
|
|
|
$this->repo->revokeClientTokens($client); |
|
30
|
|
|
$this->repo->save(['id'=> $clientId, 'revoked' => true]); |
|
31
|
|
|
}); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* UnRevoke the given client. |
|
36
|
|
|
* |
|
37
|
|
|
* @param integer $clientId |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
|
|
public function unRevoke($clientId) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->repo->save(['id'=> $clientId, 'revoked' => false]); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Ensure access token hasn't expired or revoked. |
|
47
|
|
|
* |
|
48
|
|
|
* @param string $accessToken |
|
49
|
|
|
* @return boolean |
|
50
|
|
|
*/ |
|
51
|
|
|
public function accessTokenExpiredOrRevoked($accessToken) |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->oauthClientRepository->accessTokenExpiredOrRevoked($accessToken); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Revoke the given access token and all |
|
58
|
|
|
* associated refresh tokens. |
|
59
|
|
|
* |
|
60
|
|
|
* @param oject $accessToken |
|
61
|
|
|
* @return void |
|
62
|
|
|
*/ |
|
63
|
|
|
public function revokeAccessToken($accessToken) |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->oauthClientRepository->revokeAccessToken($accessToken); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.