@@ -7,14 +7,14 @@ |
||
7 | 7 | |
8 | 8 | class PushNotificationDeviceRepository extends BaseRepository implements PushNotificationDeviceRepositoryInterface |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param PushNotificationDevice $model |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(PushNotificationDevice $model) |
|
17 | - { |
|
18 | - parent::__construct($model); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param PushNotificationDevice $model |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(PushNotificationDevice $model) |
|
17 | + { |
|
18 | + parent::__construct($model); |
|
19 | + } |
|
20 | 20 | } |
@@ -8,46 +8,46 @@ |
||
8 | 8 | |
9 | 9 | class PushNotificationDeviceController extends BaseApiController |
10 | 10 | { |
11 | - /** |
|
12 | - * Path of the sotre form request. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $storeFormRequest = 'App\Modules\Users\Http\PushNotificationDevices\StorePushNotificationDevice'; |
|
11 | + /** |
|
12 | + * Path of the sotre form request. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $storeFormRequest = 'App\Modules\Users\Http\PushNotificationDevices\StorePushNotificationDevice'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Path of the model resource |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $modelResource = 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice'; |
|
18 | + /** |
|
19 | + * Path of the model resource |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $modelResource = 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * List of all route actions that the base api controller |
|
27 | - * will skip permissions check for them. |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $skipPermissionCheck = ['registerDevice']; |
|
25 | + /** |
|
26 | + * List of all route actions that the base api controller |
|
27 | + * will skip permissions check for them. |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $skipPermissionCheck = ['registerDevice']; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Init new object. |
|
34 | - * |
|
35 | - * @param PushNotificationDeviceServiceInterface $service |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - public function __construct(PushNotificationDeviceServiceInterface $service) |
|
39 | - { |
|
40 | - parent::__construct($service); |
|
41 | - } |
|
32 | + /** |
|
33 | + * Init new object. |
|
34 | + * |
|
35 | + * @param PushNotificationDeviceServiceInterface $service |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + public function __construct(PushNotificationDeviceServiceInterface $service) |
|
39 | + { |
|
40 | + parent::__construct($service); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Register the given device to the logged in user. |
|
45 | - * |
|
46 | - * @param RegisterDevice $request |
|
47 | - * @return \Illuminate\Http\Response |
|
48 | - */ |
|
49 | - public function registerDevice(RegisterDevice $request) |
|
50 | - { |
|
51 | - return new $this->modelResource($this->service->registerDevice($request->all())); |
|
52 | - } |
|
43 | + /** |
|
44 | + * Register the given device to the logged in user. |
|
45 | + * |
|
46 | + * @param RegisterDevice $request |
|
47 | + * @return \Illuminate\Http\Response |
|
48 | + */ |
|
49 | + public function registerDevice(RegisterDevice $request) |
|
50 | + { |
|
51 | + return new $this->modelResource($this->service->registerDevice($request->all())); |
|
52 | + } |
|
53 | 53 | } |
@@ -9,38 +9,38 @@ |
||
9 | 9 | |
10 | 10 | class PushNotificationDeviceService extends BaseService implements PushNotificationDeviceServiceInterface |
11 | 11 | { |
12 | - /** |
|
13 | - * Init new object. |
|
14 | - * |
|
15 | - * @param PushNotificationDeviceRepositoryInterface $repo |
|
16 | - * @return void |
|
17 | - */ |
|
18 | - public function __construct(PushNotificationDeviceRepositoryInterface $repo) |
|
19 | - { |
|
20 | - parent::__construct($repo); |
|
21 | - } |
|
12 | + /** |
|
13 | + * Init new object. |
|
14 | + * |
|
15 | + * @param PushNotificationDeviceRepositoryInterface $repo |
|
16 | + * @return void |
|
17 | + */ |
|
18 | + public function __construct(PushNotificationDeviceRepositoryInterface $repo) |
|
19 | + { |
|
20 | + parent::__construct($repo); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Register the given device to the logged in user. |
|
25 | - * |
|
26 | - * @param array $data |
|
27 | - * @return Model |
|
28 | - */ |
|
29 | - public function registerDevice(array $data): Model |
|
30 | - { |
|
31 | - $data['access_token'] = Auth::user()->token(); |
|
32 | - $data['user_id'] = Auth::id(); |
|
33 | - $device = $this->repo->first([ |
|
34 | - 'and' => [ |
|
35 | - 'device_token' => $data['device_token'], |
|
36 | - 'user_id' => $data['user_id'] |
|
37 | - ] |
|
38 | - ]); |
|
23 | + /** |
|
24 | + * Register the given device to the logged in user. |
|
25 | + * |
|
26 | + * @param array $data |
|
27 | + * @return Model |
|
28 | + */ |
|
29 | + public function registerDevice(array $data): Model |
|
30 | + { |
|
31 | + $data['access_token'] = Auth::user()->token(); |
|
32 | + $data['user_id'] = Auth::id(); |
|
33 | + $device = $this->repo->first([ |
|
34 | + 'and' => [ |
|
35 | + 'device_token' => $data['device_token'], |
|
36 | + 'user_id' => $data['user_id'] |
|
37 | + ] |
|
38 | + ]); |
|
39 | 39 | |
40 | - if ($device) { |
|
41 | - $data['id'] = $device->id; |
|
42 | - } |
|
40 | + if ($device) { |
|
41 | + $data['id'] = $device->id; |
|
42 | + } |
|
43 | 43 | |
44 | - return $this->repo->save($data); |
|
45 | - } |
|
44 | + return $this->repo->save($data); |
|
45 | + } |
|
46 | 46 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | |
8 | 8 | interface PushNotificationDeviceServiceInterface extends BaseServiceInterface |
9 | 9 | { |
10 | - /** |
|
11 | - * Register the given device to the logged in user. |
|
12 | - * |
|
13 | - * @param array $data |
|
14 | - * @return Model |
|
15 | - */ |
|
16 | - public function registerDevice(array $data): Model; |
|
10 | + /** |
|
11 | + * Register the given device to the logged in user. |
|
12 | + * |
|
13 | + * @param array $data |
|
14 | + * @return Model |
|
15 | + */ |
|
16 | + public function registerDevice(array $data): Model; |
|
17 | 17 | } |
@@ -10,35 +10,35 @@ |
||
10 | 10 | |
11 | 11 | class ModuleServiceProvider extends ServiceProvider |
12 | 12 | { |
13 | - /** |
|
14 | - * Bootstrap the module services. |
|
15 | - * |
|
16 | - * @return void |
|
17 | - */ |
|
18 | - public function boot() |
|
19 | - { |
|
20 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'push-notification-devices'); |
|
21 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'push-notification-devices'); |
|
13 | + /** |
|
14 | + * Bootstrap the module services. |
|
15 | + * |
|
16 | + * @return void |
|
17 | + */ |
|
18 | + public function boot() |
|
19 | + { |
|
20 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'push-notification-devices'); |
|
21 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'push-notification-devices'); |
|
22 | 22 | |
23 | - $this->loadMigrationsFrom(module_path('push-notification-devices', 'Database/Migrations', 'app')); |
|
24 | - if (!$this->app->configurationIsCached()) { |
|
25 | - $this->loadConfigsFrom(module_path('push-notification-devices', 'Config', 'app')); |
|
26 | - } |
|
27 | - } |
|
23 | + $this->loadMigrationsFrom(module_path('push-notification-devices', 'Database/Migrations', 'app')); |
|
24 | + if (!$this->app->configurationIsCached()) { |
|
25 | + $this->loadConfigsFrom(module_path('push-notification-devices', 'Config', 'app')); |
|
26 | + } |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Register the module services. |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function register() |
|
35 | - { |
|
36 | - $this->app->register(RouteServiceProvider::class); |
|
29 | + /** |
|
30 | + * Register the module services. |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function register() |
|
35 | + { |
|
36 | + $this->app->register(RouteServiceProvider::class); |
|
37 | 37 | |
38 | - /** |
|
39 | - * Bind interfaces to implmentations. |
|
40 | - */ |
|
41 | - $this->app->bind(PushNotificationDeviceServiceInterface::class, PushNotificationDeviceService::class); |
|
42 | - $this->app->bind(PushNotificationDeviceRepositoryInterface::class, PushNotificationDeviceRepository::class); |
|
43 | - } |
|
38 | + /** |
|
39 | + * Bind interfaces to implmentations. |
|
40 | + */ |
|
41 | + $this->app->bind(PushNotificationDeviceServiceInterface::class, PushNotificationDeviceService::class); |
|
42 | + $this->app->bind(PushNotificationDeviceRepositoryInterface::class, PushNotificationDeviceRepository::class); |
|
43 | + } |
|
44 | 44 | } |
@@ -6,29 +6,29 @@ |
||
6 | 6 | |
7 | 7 | interface OauthClientRepositoryInterface extends BaseRepositoryInterface |
8 | 8 | { |
9 | - /** |
|
10 | - * Revoke the given client tokens. |
|
11 | - * |
|
12 | - * @param mixed $client |
|
13 | - * @return bool |
|
14 | - */ |
|
15 | - public function revokeClientTokens($client): bool; |
|
9 | + /** |
|
10 | + * Revoke the given client tokens. |
|
11 | + * |
|
12 | + * @param mixed $client |
|
13 | + * @return bool |
|
14 | + */ |
|
15 | + public function revokeClientTokens($client): bool; |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Ensure access token hasn't expired or revoked. |
|
20 | - * |
|
21 | - * @param string $accessToken |
|
22 | - * @return bool |
|
23 | - */ |
|
24 | - public function accessTokenExpiredOrRevoked(string $accessToken): bool; |
|
18 | + /** |
|
19 | + * Ensure access token hasn't expired or revoked. |
|
20 | + * |
|
21 | + * @param string $accessToken |
|
22 | + * @return bool |
|
23 | + */ |
|
24 | + public function accessTokenExpiredOrRevoked(string $accessToken): bool; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Revoke the given access token and all |
|
28 | - * associated refresh tokens. |
|
29 | - * |
|
30 | - * @param oject $accessToken |
|
31 | - * @return bool |
|
32 | - */ |
|
33 | - public function revokeAccessToken(object $accessToken): bool; |
|
26 | + /** |
|
27 | + * Revoke the given access token and all |
|
28 | + * associated refresh tokens. |
|
29 | + * |
|
30 | + * @param oject $accessToken |
|
31 | + * @return bool |
|
32 | + */ |
|
33 | + public function revokeAccessToken(object $accessToken): bool; |
|
34 | 34 | } |
@@ -8,68 +8,68 @@ |
||
8 | 8 | |
9 | 9 | class OauthClientRepository extends BaseRepository implements OauthClientRepositoryInterface |
10 | 10 | { |
11 | - /** |
|
12 | - * Init new object. |
|
13 | - * |
|
14 | - * @param OauthClient $model |
|
15 | - * @return void |
|
16 | - */ |
|
17 | - public function __construct(OauthClient $model) |
|
18 | - { |
|
19 | - parent::__construct($model); |
|
20 | - } |
|
11 | + /** |
|
12 | + * Init new object. |
|
13 | + * |
|
14 | + * @param OauthClient $model |
|
15 | + * @return void |
|
16 | + */ |
|
17 | + public function __construct(OauthClient $model) |
|
18 | + { |
|
19 | + parent::__construct($model); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Revoke the given client tokens. |
|
24 | - * |
|
25 | - * @param mixed $client |
|
26 | - * @return bool |
|
27 | - */ |
|
28 | - public function revokeClientTokens($client): bool |
|
29 | - { |
|
30 | - $client = ! filter_var($client, FILTER_VALIDATE_INT) ? $client : $this->find($client); |
|
31 | - $client->tokens()->update(['revoked' => true]); |
|
22 | + /** |
|
23 | + * Revoke the given client tokens. |
|
24 | + * |
|
25 | + * @param mixed $client |
|
26 | + * @return bool |
|
27 | + */ |
|
28 | + public function revokeClientTokens($client): bool |
|
29 | + { |
|
30 | + $client = ! filter_var($client, FILTER_VALIDATE_INT) ? $client : $this->find($client); |
|
31 | + $client->tokens()->update(['revoked' => true]); |
|
32 | 32 | |
33 | - return true; |
|
34 | - } |
|
33 | + return true; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Ensure access token hasn't expired or revoked. |
|
38 | - * |
|
39 | - * @param string $accessToken |
|
40 | - * @return bool |
|
41 | - */ |
|
42 | - public function accessTokenExpiredOrRevoked(string $accessToken): bool |
|
43 | - { |
|
44 | - $accessTokenId = json_decode($accessToken, true)['id']; |
|
45 | - $accessToken = DB::table('oauth_access_tokens') |
|
46 | - ->where('id', $accessTokenId) |
|
47 | - ->first(); |
|
36 | + /** |
|
37 | + * Ensure access token hasn't expired or revoked. |
|
38 | + * |
|
39 | + * @param string $accessToken |
|
40 | + * @return bool |
|
41 | + */ |
|
42 | + public function accessTokenExpiredOrRevoked(string $accessToken): bool |
|
43 | + { |
|
44 | + $accessTokenId = json_decode($accessToken, true)['id']; |
|
45 | + $accessToken = DB::table('oauth_access_tokens') |
|
46 | + ->where('id', $accessTokenId) |
|
47 | + ->first(); |
|
48 | 48 | |
49 | - if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) { |
|
50 | - return true; |
|
51 | - } |
|
49 | + if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) { |
|
50 | + return true; |
|
51 | + } |
|
52 | 52 | |
53 | - return false; |
|
54 | - } |
|
53 | + return false; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Revoke the given access token and all |
|
58 | - * associated refresh tokens. |
|
59 | - * |
|
60 | - * @param oject $accessToken |
|
61 | - * @return bool |
|
62 | - */ |
|
63 | - public function revokeAccessToken(object $accessToken): bool |
|
64 | - { |
|
65 | - DB::table('oauth_refresh_tokens') |
|
66 | - ->where('access_token_id', $accessToken->id) |
|
67 | - ->update([ |
|
68 | - 'revoked' => true |
|
69 | - ]); |
|
56 | + /** |
|
57 | + * Revoke the given access token and all |
|
58 | + * associated refresh tokens. |
|
59 | + * |
|
60 | + * @param oject $accessToken |
|
61 | + * @return bool |
|
62 | + */ |
|
63 | + public function revokeAccessToken(object $accessToken): bool |
|
64 | + { |
|
65 | + DB::table('oauth_refresh_tokens') |
|
66 | + ->where('access_token_id', $accessToken->id) |
|
67 | + ->update([ |
|
68 | + 'revoked' => true |
|
69 | + ]); |
|
70 | 70 | |
71 | - $accessToken->revoke(); |
|
71 | + $accessToken->revoke(); |
|
72 | 72 | |
73 | - return true; |
|
74 | - } |
|
73 | + return true; |
|
74 | + } |
|
75 | 75 | } |
@@ -8,50 +8,50 @@ |
||
8 | 8 | |
9 | 9 | class OauthClientController extends BaseApiController |
10 | 10 | { |
11 | - /** |
|
12 | - * Path of the sotre form request. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $storeFormRequest = 'App\Modules\OauthClients\Http\Requests\StoreOauthClient'; |
|
11 | + /** |
|
12 | + * Path of the sotre form request. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $storeFormRequest = 'App\Modules\OauthClients\Http\Requests\StoreOauthClient'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Path of the model resource |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $modelResource = 'App\Modules\OauthClients\Http\Resources\OauthClient'; |
|
18 | + /** |
|
19 | + * Path of the model resource |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $modelResource = 'App\Modules\OauthClients\Http\Resources\OauthClient'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Init new object. |
|
27 | - * |
|
28 | - * @param OauthClientServiceInterface $service |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function __construct(OauthClientServiceInterface $service) |
|
32 | - { |
|
33 | - parent::__construct($service); |
|
34 | - } |
|
25 | + /** |
|
26 | + * Init new object. |
|
27 | + * |
|
28 | + * @param OauthClientServiceInterface $service |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function __construct(OauthClientServiceInterface $service) |
|
32 | + { |
|
33 | + parent::__construct($service); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Revoke the given client. |
|
38 | - * |
|
39 | - * @param integer $clientId Id of the client |
|
40 | - * @return \Illuminate\Http\Response |
|
41 | - */ |
|
42 | - public function revoke($clientId) |
|
43 | - { |
|
44 | - return new GeneralResource($this->service->revoke($clientId)); |
|
45 | - } |
|
36 | + /** |
|
37 | + * Revoke the given client. |
|
38 | + * |
|
39 | + * @param integer $clientId Id of the client |
|
40 | + * @return \Illuminate\Http\Response |
|
41 | + */ |
|
42 | + public function revoke($clientId) |
|
43 | + { |
|
44 | + return new GeneralResource($this->service->revoke($clientId)); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Un revoke the given client. |
|
49 | - * |
|
50 | - * @param integer $clientId Id of the client |
|
51 | - * @return \Illuminate\Http\Response |
|
52 | - */ |
|
53 | - public function unRevoke($clientId) |
|
54 | - { |
|
55 | - return new GeneralResource($this->service->unRevoke($clientId)); |
|
56 | - } |
|
47 | + /** |
|
48 | + * Un revoke the given client. |
|
49 | + * |
|
50 | + * @param integer $clientId Id of the client |
|
51 | + * @return \Illuminate\Http\Response |
|
52 | + */ |
|
53 | + public function unRevoke($clientId) |
|
54 | + { |
|
55 | + return new GeneralResource($this->service->unRevoke($clientId)); |
|
56 | + } |
|
57 | 57 | } |
@@ -7,37 +7,37 @@ |
||
7 | 7 | |
8 | 8 | interface OauthClientServiceInterface extends BaseServiceInterface |
9 | 9 | { |
10 | - /** |
|
11 | - * Revoke the given client. |
|
12 | - * |
|
13 | - * @param int $clientId |
|
14 | - * @return Model |
|
15 | - */ |
|
16 | - public function revoke(int $clientId): Model; |
|
10 | + /** |
|
11 | + * Revoke the given client. |
|
12 | + * |
|
13 | + * @param int $clientId |
|
14 | + * @return Model |
|
15 | + */ |
|
16 | + public function revoke(int $clientId): Model; |
|
17 | 17 | |
18 | - /** |
|
19 | - * UnRevoke the given client. |
|
20 | - * |
|
21 | - * @param int $clientId |
|
22 | - * @return Model |
|
23 | - */ |
|
24 | - public function unRevoke(int $clientId): Model; |
|
18 | + /** |
|
19 | + * UnRevoke the given client. |
|
20 | + * |
|
21 | + * @param int $clientId |
|
22 | + * @return Model |
|
23 | + */ |
|
24 | + public function unRevoke(int $clientId): Model; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Ensure access token hasn't expired or revoked. |
|
28 | - * |
|
29 | - * @param string $accessToken |
|
30 | - * @return bool |
|
31 | - */ |
|
32 | - public function accessTokenExpiredOrRevoked(string $accessToken): bool; |
|
26 | + /** |
|
27 | + * Ensure access token hasn't expired or revoked. |
|
28 | + * |
|
29 | + * @param string $accessToken |
|
30 | + * @return bool |
|
31 | + */ |
|
32 | + public function accessTokenExpiredOrRevoked(string $accessToken): bool; |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Revoke the given access token and all |
|
37 | - * associated refresh tokens. |
|
38 | - * |
|
39 | - * @param oject $accessToken |
|
40 | - * @return bool |
|
41 | - */ |
|
42 | - public function revokeAccessToken(object $accessToken): bool; |
|
35 | + /** |
|
36 | + * Revoke the given access token and all |
|
37 | + * associated refresh tokens. |
|
38 | + * |
|
39 | + * @param oject $accessToken |
|
40 | + * @return bool |
|
41 | + */ |
|
42 | + public function revokeAccessToken(object $accessToken): bool; |
|
43 | 43 | } |