@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class StoreUser extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'name' => 'nullable|string', |
|
28 | - 'email' => 'required|email|unique:users,email,' . $this->route('id'), |
|
29 | - 'password' => 'nullable|min:6' |
|
30 | - ]; |
|
31 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'name' => 'nullable|string', |
|
28 | + 'email' => 'required|email|unique:users,email,' . $this->route('id'), |
|
29 | + 'password' => 'nullable|min:6' |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | return [ |
27 | 27 | 'name' => 'nullable|string', |
28 | - 'email' => 'required|email|unique:users,email,' . $this->route('id'), |
|
28 | + 'email' => 'required|email|unique:users,email,'.$this->route('id'), |
|
29 | 29 | 'password' => 'nullable|min:6' |
30 | 30 | ]; |
31 | 31 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class AssignRoles extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'role_ids' => 'required|array', |
|
28 | - 'role_ids.*' => 'required|exists:roles,id' |
|
29 | - ]; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'role_ids' => 'required|array', |
|
28 | + 'role_ids.*' => 'required|exists:roles,id' |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -12,112 +12,112 @@ |
||
12 | 12 | |
13 | 13 | class AclUser extends User |
14 | 14 | { |
15 | - use SoftDeletes, HasApiTokens; |
|
16 | - protected $table = 'users'; |
|
17 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
18 | - protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
19 | - protected $guarded = ['id']; |
|
20 | - public $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone', 'blocked', 'confirmed']; |
|
21 | - |
|
22 | - /** |
|
23 | - * Encrypt the password attribute before |
|
24 | - * saving it in the storage. |
|
25 | - * |
|
26 | - * @param string $value |
|
27 | - */ |
|
28 | - public function setPasswordAttribute($value) |
|
29 | - { |
|
30 | - $this->attributes['password'] = \Hash::make($value); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * Get the entity's notifications. |
|
35 | - */ |
|
36 | - public function notifications() |
|
37 | - { |
|
38 | - return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc'); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Get the entity's read notifications. |
|
43 | - */ |
|
44 | - public function readNotifications() |
|
45 | - { |
|
46 | - return $this->notifications()->whereNotNull('read_at'); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Get the entity's unread notifications. |
|
51 | - */ |
|
52 | - public function unreadNotifications() |
|
53 | - { |
|
54 | - return $this->notifications()->whereNull('read_at'); |
|
55 | - } |
|
56 | - |
|
57 | - public function roles() |
|
58 | - { |
|
59 | - return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
60 | - } |
|
61 | - |
|
62 | - public function oauthClients() |
|
63 | - { |
|
64 | - return $this->hasMany(OauthClient::class, 'user_id'); |
|
65 | - } |
|
66 | - |
|
67 | - public function setProfilePictureAttribute($value) { |
|
68 | - $this->attributes['profile_picture'] = \Media::uploadImageBas64($value, 'users/profile_pictures'); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Return fcm device tokens that will be used in sending fcm notifications. |
|
73 | - * |
|
74 | - * @return array |
|
75 | - */ |
|
76 | - public function routeNotificationForFCM() |
|
77 | - { |
|
78 | - $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
79 | - $tokens = []; |
|
80 | - |
|
81 | - foreach ($devices as $device) { |
|
82 | - if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
83 | - $device->forceDelete(); |
|
84 | - continue; |
|
85 | - } |
|
86 | - |
|
87 | - $tokens[] = $device->device_token; |
|
88 | - } |
|
89 | - |
|
90 | - return $tokens; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * The channels the user receives notification broadcasts on. |
|
95 | - * |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function receivesBroadcastNotificationsOn() |
|
99 | - { |
|
100 | - return 'users.'.$this->id; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Custom password validation. |
|
105 | - * |
|
106 | - * @param string $password |
|
107 | - * @return boolean |
|
108 | - */ |
|
109 | - public function validateForPassportPasswordGrant($password) |
|
110 | - { |
|
111 | - if ($password == config('user.social_pass')) { |
|
112 | - return true; |
|
113 | - } |
|
114 | - |
|
115 | - return \Hash::check($password, $this->password); |
|
116 | - } |
|
15 | + use SoftDeletes, HasApiTokens; |
|
16 | + protected $table = 'users'; |
|
17 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
18 | + protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
19 | + protected $guarded = ['id']; |
|
20 | + public $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone', 'blocked', 'confirmed']; |
|
21 | + |
|
22 | + /** |
|
23 | + * Encrypt the password attribute before |
|
24 | + * saving it in the storage. |
|
25 | + * |
|
26 | + * @param string $value |
|
27 | + */ |
|
28 | + public function setPasswordAttribute($value) |
|
29 | + { |
|
30 | + $this->attributes['password'] = \Hash::make($value); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * Get the entity's notifications. |
|
35 | + */ |
|
36 | + public function notifications() |
|
37 | + { |
|
38 | + return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc'); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Get the entity's read notifications. |
|
43 | + */ |
|
44 | + public function readNotifications() |
|
45 | + { |
|
46 | + return $this->notifications()->whereNotNull('read_at'); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Get the entity's unread notifications. |
|
51 | + */ |
|
52 | + public function unreadNotifications() |
|
53 | + { |
|
54 | + return $this->notifications()->whereNull('read_at'); |
|
55 | + } |
|
56 | + |
|
57 | + public function roles() |
|
58 | + { |
|
59 | + return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
60 | + } |
|
61 | + |
|
62 | + public function oauthClients() |
|
63 | + { |
|
64 | + return $this->hasMany(OauthClient::class, 'user_id'); |
|
65 | + } |
|
66 | + |
|
67 | + public function setProfilePictureAttribute($value) { |
|
68 | + $this->attributes['profile_picture'] = \Media::uploadImageBas64($value, 'users/profile_pictures'); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Return fcm device tokens that will be used in sending fcm notifications. |
|
73 | + * |
|
74 | + * @return array |
|
75 | + */ |
|
76 | + public function routeNotificationForFCM() |
|
77 | + { |
|
78 | + $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
79 | + $tokens = []; |
|
80 | + |
|
81 | + foreach ($devices as $device) { |
|
82 | + if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
83 | + $device->forceDelete(); |
|
84 | + continue; |
|
85 | + } |
|
86 | + |
|
87 | + $tokens[] = $device->device_token; |
|
88 | + } |
|
89 | + |
|
90 | + return $tokens; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * The channels the user receives notification broadcasts on. |
|
95 | + * |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function receivesBroadcastNotificationsOn() |
|
99 | + { |
|
100 | + return 'users.'.$this->id; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Custom password validation. |
|
105 | + * |
|
106 | + * @param string $password |
|
107 | + * @return boolean |
|
108 | + */ |
|
109 | + public function validateForPassportPasswordGrant($password) |
|
110 | + { |
|
111 | + if ($password == config('user.social_pass')) { |
|
112 | + return true; |
|
113 | + } |
|
114 | + |
|
115 | + return \Hash::check($password, $this->password); |
|
116 | + } |
|
117 | 117 | |
118 | - public static function boot() |
|
119 | - { |
|
120 | - parent::boot(); |
|
121 | - AclUser::observe(AclUserObserver::class); |
|
122 | - } |
|
118 | + public static function boot() |
|
119 | + { |
|
120 | + parent::boot(); |
|
121 | + AclUser::observe(AclUserObserver::class); |
|
122 | + } |
|
123 | 123 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class AssignPermissions extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'permission_ids' => 'required|array', |
|
28 | - 'permission_ids.*' => 'required|exists:permissions,id' |
|
29 | - ]; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'permission_ids' => 'required|array', |
|
28 | + 'permission_ids.*' => 'required|exists:permissions,id' |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class StoreRole extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'name' => 'required|string|max:100|unique:roles,name,' . $this->route('id') |
|
28 | - ]; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'name' => 'required|string|max:100|unique:roles,name,' . $this->route('id') |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | public function rules() |
25 | 25 | { |
26 | 26 | return [ |
27 | - 'name' => 'required|string|max:100|unique:roles,name,' . $this->route('id') |
|
27 | + 'name' => 'required|string|max:100|unique:roles,name,'.$this->route('id') |
|
28 | 28 | ]; |
29 | 29 | } |
30 | 30 | } |
@@ -7,39 +7,39 @@ |
||
7 | 7 | |
8 | 8 | class RoleRepository extends BaseRepository |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param Role $model |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(Role $model) |
|
17 | - { |
|
18 | - parent::__construct($model); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param Role $model |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(Role $model) |
|
17 | + { |
|
18 | + parent::__construct($model); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Detach all permissions from the given role. |
|
23 | - * |
|
24 | - * @param mixed $role |
|
25 | - * @return object |
|
26 | - */ |
|
27 | - public function detachPermissions($role) |
|
28 | - { |
|
29 | - $role = ! filter_var($role, FILTER_VALIDATE_INT) ? $role : $this->find($role); |
|
30 | - $role->permissions()->detach(); |
|
31 | - } |
|
21 | + /** |
|
22 | + * Detach all permissions from the given role. |
|
23 | + * |
|
24 | + * @param mixed $role |
|
25 | + * @return object |
|
26 | + */ |
|
27 | + public function detachPermissions($role) |
|
28 | + { |
|
29 | + $role = ! filter_var($role, FILTER_VALIDATE_INT) ? $role : $this->find($role); |
|
30 | + $role->permissions()->detach(); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Attach permission ids to the given role. |
|
35 | - * |
|
36 | - * @param mixed $role |
|
37 | - * @param array $permissionIds |
|
38 | - * @return object |
|
39 | - */ |
|
40 | - public function attachPermissions($role, $permissionIds) |
|
41 | - { |
|
42 | - $role = ! filter_var($role, FILTER_VALIDATE_INT) ? $role : $this->find($role); |
|
43 | - $role->permissions()->attach($permissionIds); |
|
44 | - } |
|
33 | + /** |
|
34 | + * Attach permission ids to the given role. |
|
35 | + * |
|
36 | + * @param mixed $role |
|
37 | + * @param array $permissionIds |
|
38 | + * @return object |
|
39 | + */ |
|
40 | + public function attachPermissions($role, $permissionIds) |
|
41 | + { |
|
42 | + $role = ! filter_var($role, FILTER_VALIDATE_INT) ? $role : $this->find($role); |
|
43 | + $role->permissions()->attach($permissionIds); |
|
44 | + } |
|
45 | 45 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | public function revoke($clientId) |
28 | 28 | { |
29 | - \DB::transaction(function () use ($clientId) { |
|
29 | + \DB::transaction(function() use ($clientId) { |
|
30 | 30 | $client = $this->repo->find($clientId); |
31 | 31 | $this->repo->revokeClientTokens($client); |
32 | 32 | $this->repo->save(['id'=> $clientId, 'revoked' => true]); |
@@ -7,63 +7,63 @@ |
||
7 | 7 | |
8 | 8 | class OauthClientService extends BaseService |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param OauthClientRepository $repo |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(OauthClientRepository $repo) |
|
17 | - { |
|
18 | - parent::__construct($repo); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param OauthClientRepository $repo |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(OauthClientRepository $repo) |
|
17 | + { |
|
18 | + parent::__construct($repo); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Revoke the given client. |
|
23 | - * |
|
24 | - * @param integer $clientId |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function revoke($clientId) |
|
28 | - { |
|
29 | - \DB::transaction(function () use ($clientId) { |
|
30 | - $client = $this->repo->find($clientId); |
|
31 | - $this->repo->revokeClientTokens($client); |
|
32 | - $this->repo->save(['id'=> $clientId, 'revoked' => true]); |
|
33 | - }); |
|
34 | - } |
|
21 | + /** |
|
22 | + * Revoke the given client. |
|
23 | + * |
|
24 | + * @param integer $clientId |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function revoke($clientId) |
|
28 | + { |
|
29 | + \DB::transaction(function () use ($clientId) { |
|
30 | + $client = $this->repo->find($clientId); |
|
31 | + $this->repo->revokeClientTokens($client); |
|
32 | + $this->repo->save(['id'=> $clientId, 'revoked' => true]); |
|
33 | + }); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * UnRevoke the given client. |
|
38 | - * |
|
39 | - * @param integer $clientId |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function unRevoke($clientId) |
|
43 | - { |
|
44 | - $this->repo->save(['id'=> $clientId, 'revoked' => false]); |
|
45 | - } |
|
36 | + /** |
|
37 | + * UnRevoke the given client. |
|
38 | + * |
|
39 | + * @param integer $clientId |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function unRevoke($clientId) |
|
43 | + { |
|
44 | + $this->repo->save(['id'=> $clientId, 'revoked' => false]); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Ensure access token hasn't expired or revoked. |
|
49 | - * |
|
50 | - * @param string $accessToken |
|
51 | - * @return boolean |
|
52 | - */ |
|
53 | - public function accessTokenExpiredOrRevoked($accessToken) |
|
54 | - { |
|
55 | - return $this->repo->accessTokenExpiredOrRevoked($accessToken); |
|
56 | - } |
|
47 | + /** |
|
48 | + * Ensure access token hasn't expired or revoked. |
|
49 | + * |
|
50 | + * @param string $accessToken |
|
51 | + * @return boolean |
|
52 | + */ |
|
53 | + public function accessTokenExpiredOrRevoked($accessToken) |
|
54 | + { |
|
55 | + return $this->repo->accessTokenExpiredOrRevoked($accessToken); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Revoke the given access token and all |
|
60 | - * associated refresh tokens. |
|
61 | - * |
|
62 | - * @param oject $accessToken |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public function revokeAccessToken($accessToken) |
|
66 | - { |
|
67 | - return $this->repo->revokeAccessToken($accessToken); |
|
68 | - } |
|
58 | + /** |
|
59 | + * Revoke the given access token and all |
|
60 | + * associated refresh tokens. |
|
61 | + * |
|
62 | + * @param oject $accessToken |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public function revokeAccessToken($accessToken) |
|
66 | + { |
|
67 | + return $this->repo->revokeAccessToken($accessToken); |
|
68 | + } |
|
69 | 69 | } |
@@ -7,64 +7,64 @@ |
||
7 | 7 | |
8 | 8 | class OauthClientRepository extends BaseRepository |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param OauthClient $model |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(OauthClient $model) |
|
17 | - { |
|
18 | - parent::__construct($model); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param OauthClient $model |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(OauthClient $model) |
|
17 | + { |
|
18 | + parent::__construct($model); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Revoke the given client tokens. |
|
23 | - * |
|
24 | - * @param mixed $client |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function revokeClientTokens($client) |
|
28 | - { |
|
29 | - $client = ! filter_var($client, FILTER_VALIDATE_INT) ? $client : $this->find($client); |
|
30 | - $client->tokens()->update(['revoked' => true]); |
|
31 | - } |
|
21 | + /** |
|
22 | + * Revoke the given client tokens. |
|
23 | + * |
|
24 | + * @param mixed $client |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function revokeClientTokens($client) |
|
28 | + { |
|
29 | + $client = ! filter_var($client, FILTER_VALIDATE_INT) ? $client : $this->find($client); |
|
30 | + $client->tokens()->update(['revoked' => true]); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Ensure access token hasn't expired or revoked. |
|
35 | - * |
|
36 | - * @param string $accessToken |
|
37 | - * @return boolean |
|
38 | - */ |
|
39 | - public function accessTokenExpiredOrRevoked($accessToken) |
|
40 | - { |
|
41 | - $accessTokenId = json_decode($accessToken, true)['id']; |
|
42 | - $accessToken = \DB::table('oauth_access_tokens') |
|
43 | - ->where('id', $accessTokenId) |
|
44 | - ->first(); |
|
33 | + /** |
|
34 | + * Ensure access token hasn't expired or revoked. |
|
35 | + * |
|
36 | + * @param string $accessToken |
|
37 | + * @return boolean |
|
38 | + */ |
|
39 | + public function accessTokenExpiredOrRevoked($accessToken) |
|
40 | + { |
|
41 | + $accessTokenId = json_decode($accessToken, true)['id']; |
|
42 | + $accessToken = \DB::table('oauth_access_tokens') |
|
43 | + ->where('id', $accessTokenId) |
|
44 | + ->first(); |
|
45 | 45 | |
46 | - if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) { |
|
47 | - return true; |
|
48 | - } |
|
46 | + if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) { |
|
47 | + return true; |
|
48 | + } |
|
49 | 49 | |
50 | - return false; |
|
51 | - } |
|
50 | + return false; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Revoke the given access token and all |
|
55 | - * associated refresh tokens. |
|
56 | - * |
|
57 | - * @param oject $accessToken |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function revokeAccessToken($accessToken) |
|
61 | - { |
|
62 | - \DB::table('oauth_refresh_tokens') |
|
63 | - ->where('access_token_id', $accessToken->id) |
|
64 | - ->update([ |
|
65 | - 'revoked' => true |
|
66 | - ]); |
|
53 | + /** |
|
54 | + * Revoke the given access token and all |
|
55 | + * associated refresh tokens. |
|
56 | + * |
|
57 | + * @param oject $accessToken |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function revokeAccessToken($accessToken) |
|
61 | + { |
|
62 | + \DB::table('oauth_refresh_tokens') |
|
63 | + ->where('access_token_id', $accessToken->id) |
|
64 | + ->update([ |
|
65 | + 'revoked' => true |
|
66 | + ]); |
|
67 | 67 | |
68 | - $accessToken->revoke(); |
|
69 | - } |
|
68 | + $accessToken->revoke(); |
|
69 | + } |
|
70 | 70 | } |
@@ -6,30 +6,30 @@ |
||
6 | 6 | |
7 | 7 | class Core implements BaseFactoryInterface |
8 | 8 | { |
9 | - /** |
|
10 | - * Construct the repository class name based on |
|
11 | - * the method name called, search in the |
|
12 | - * given namespaces for the class and |
|
13 | - * return an instance. |
|
14 | - * |
|
15 | - * @param string $name the called method name |
|
16 | - * @param array $arguments the method arguments |
|
17 | - * @return object |
|
18 | - */ |
|
19 | - public function __call($name, $arguments) |
|
20 | - { |
|
21 | - foreach (\Module::all() as $module) { |
|
22 | - $nameSpace = 'App\\Modules\\' . $module['basename'] ; |
|
23 | - $model = ucfirst(\Str::singular($name)); |
|
24 | - if(count($arguments) == 1 && $arguments[0]) { |
|
25 | - $class = $nameSpace . '\\Services\\' . $model . 'Service'; |
|
26 | - } else { |
|
27 | - $class = $nameSpace . '\\Repositories\\' . $model . 'Repository'; |
|
28 | - } |
|
9 | + /** |
|
10 | + * Construct the repository class name based on |
|
11 | + * the method name called, search in the |
|
12 | + * given namespaces for the class and |
|
13 | + * return an instance. |
|
14 | + * |
|
15 | + * @param string $name the called method name |
|
16 | + * @param array $arguments the method arguments |
|
17 | + * @return object |
|
18 | + */ |
|
19 | + public function __call($name, $arguments) |
|
20 | + { |
|
21 | + foreach (\Module::all() as $module) { |
|
22 | + $nameSpace = 'App\\Modules\\' . $module['basename'] ; |
|
23 | + $model = ucfirst(\Str::singular($name)); |
|
24 | + if(count($arguments) == 1 && $arguments[0]) { |
|
25 | + $class = $nameSpace . '\\Services\\' . $model . 'Service'; |
|
26 | + } else { |
|
27 | + $class = $nameSpace . '\\Repositories\\' . $model . 'Repository'; |
|
28 | + } |
|
29 | 29 | |
30 | - if (class_exists($class)) { |
|
31 | - return \App::make($class); |
|
32 | - } |
|
33 | - } |
|
34 | - } |
|
30 | + if (class_exists($class)) { |
|
31 | + return \App::make($class); |
|
32 | + } |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
@@ -19,12 +19,12 @@ |
||
19 | 19 | public function __call($name, $arguments) |
20 | 20 | { |
21 | 21 | foreach (\Module::all() as $module) { |
22 | - $nameSpace = 'App\\Modules\\' . $module['basename'] ; |
|
22 | + $nameSpace = 'App\\Modules\\'.$module['basename']; |
|
23 | 23 | $model = ucfirst(\Str::singular($name)); |
24 | - if(count($arguments) == 1 && $arguments[0]) { |
|
25 | - $class = $nameSpace . '\\Services\\' . $model . 'Service'; |
|
24 | + if (count($arguments) == 1 && $arguments[0]) { |
|
25 | + $class = $nameSpace.'\\Services\\'.$model.'Service'; |
|
26 | 26 | } else { |
27 | - $class = $nameSpace . '\\Repositories\\' . $model . 'Repository'; |
|
27 | + $class = $nameSpace.'\\Repositories\\'.$model.'Repository'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | if (class_exists($class)) { |