@@ -9,37 +9,37 @@ |
||
9 | 9 | |
10 | 10 | class Kernel extends ConsoleKernel |
11 | 11 | { |
12 | - /** |
|
13 | - * The Artisan commands provided by your application. |
|
14 | - * |
|
15 | - * @var array |
|
16 | - */ |
|
17 | - protected $commands = [ |
|
18 | - GenerateDoc::class, |
|
19 | - MakeNotificationsCommand::class |
|
20 | - ]; |
|
12 | + /** |
|
13 | + * The Artisan commands provided by your application. |
|
14 | + * |
|
15 | + * @var array |
|
16 | + */ |
|
17 | + protected $commands = [ |
|
18 | + GenerateDoc::class, |
|
19 | + MakeNotificationsCommand::class |
|
20 | + ]; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Define the application's command schedule. |
|
24 | - * |
|
25 | - * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - protected function schedule(Schedule $schedule) |
|
29 | - { |
|
30 | - // $schedule->command('inspire') |
|
31 | - // ->hourly(); |
|
32 | - } |
|
22 | + /** |
|
23 | + * Define the application's command schedule. |
|
24 | + * |
|
25 | + * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + protected function schedule(Schedule $schedule) |
|
29 | + { |
|
30 | + // $schedule->command('inspire') |
|
31 | + // ->hourly(); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Register the commands for the application. |
|
36 | - * |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - protected function commands() |
|
40 | - { |
|
41 | - $this->load(__DIR__.'/Commands'); |
|
34 | + /** |
|
35 | + * Register the commands for the application. |
|
36 | + * |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + protected function commands() |
|
40 | + { |
|
41 | + $this->load(__DIR__.'/Commands'); |
|
42 | 42 | |
43 | - require base_path('routes/console.php'); |
|
44 | - } |
|
43 | + require base_path('routes/console.php'); |
|
44 | + } |
|
45 | 45 | } |
@@ -10,43 +10,43 @@ |
||
10 | 10 | |
11 | 11 | class ResetPassword extends Notification implements ShouldQueue |
12 | 12 | { |
13 | - use Queueable; |
|
13 | + use Queueable; |
|
14 | 14 | |
15 | - protected $token; |
|
15 | + protected $token; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Create a new notification instance. |
|
19 | - * |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function __construct($token) |
|
23 | - { |
|
24 | - $this->token = $token; |
|
25 | - } |
|
17 | + /** |
|
18 | + * Create a new notification instance. |
|
19 | + * |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function __construct($token) |
|
23 | + { |
|
24 | + $this->token = $token; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Get the notification's delivery channels. |
|
29 | - * |
|
30 | - * @param mixed $notifiable |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function via($notifiable) |
|
34 | - { |
|
35 | - return ['mail']; |
|
36 | - } |
|
27 | + /** |
|
28 | + * Get the notification's delivery channels. |
|
29 | + * |
|
30 | + * @param mixed $notifiable |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function via($notifiable) |
|
34 | + { |
|
35 | + return ['mail']; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get the mail representation of the notification. |
|
40 | - * |
|
41 | - * @param mixed $notifiable |
|
42 | - * @return \Illuminate\Notifications\Messages\MailMessage |
|
43 | - */ |
|
44 | - public function toMail($notifiable) |
|
45 | - { |
|
46 | - return (new MailMessage) |
|
47 | - ->subject('Reset passowrd') |
|
48 | - ->line('Reset passowrd') |
|
49 | - ->line('To reset your password click on the button below') |
|
50 | - ->action('Reset password', config('skeleton.reset_password_url') . '/' . $this->token); |
|
51 | - } |
|
38 | + /** |
|
39 | + * Get the mail representation of the notification. |
|
40 | + * |
|
41 | + * @param mixed $notifiable |
|
42 | + * @return \Illuminate\Notifications\Messages\MailMessage |
|
43 | + */ |
|
44 | + public function toMail($notifiable) |
|
45 | + { |
|
46 | + return (new MailMessage) |
|
47 | + ->subject('Reset passowrd') |
|
48 | + ->line('Reset passowrd') |
|
49 | + ->line('To reset your password click on the button below') |
|
50 | + ->action('Reset password', config('skeleton.reset_password_url') . '/' . $this->token); |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -47,6 +47,6 @@ |
||
47 | 47 | ->subject('Reset passowrd') |
48 | 48 | ->line('Reset passowrd') |
49 | 49 | ->line('To reset your password click on the button below') |
50 | - ->action('Reset password', config('skeleton.reset_password_url') . '/' . $this->token); |
|
50 | + ->action('Reset password', config('skeleton.reset_password_url').'/'.$this->token); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -10,41 +10,41 @@ |
||
10 | 10 | |
11 | 11 | class ConfirmEmail extends Notification implements ShouldQueue |
12 | 12 | { |
13 | - use Queueable; |
|
13 | + use Queueable; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Create a new notification instance. |
|
17 | - * |
|
18 | - * @return void |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - // |
|
23 | - } |
|
15 | + /** |
|
16 | + * Create a new notification instance. |
|
17 | + * |
|
18 | + * @return void |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + // |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Get the notification's delivery channels. |
|
27 | - * |
|
28 | - * @param mixed $notifiable |
|
29 | - * @return array |
|
30 | - */ |
|
31 | - public function via($notifiable) |
|
32 | - { |
|
33 | - return ['mail']; |
|
34 | - } |
|
25 | + /** |
|
26 | + * Get the notification's delivery channels. |
|
27 | + * |
|
28 | + * @param mixed $notifiable |
|
29 | + * @return array |
|
30 | + */ |
|
31 | + public function via($notifiable) |
|
32 | + { |
|
33 | + return ['mail']; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Get the mail representation of the notification. |
|
38 | - * |
|
39 | - * @param mixed $notifiable |
|
40 | - * @return \Illuminate\Notifications\Messages\MailMessage |
|
41 | - */ |
|
42 | - public function toMail($notifiable) |
|
43 | - { |
|
44 | - return (new MailMessage) |
|
45 | - ->subject('Email verification') |
|
46 | - ->line('Email verification') |
|
47 | - ->line('To validate your email click on the button below') |
|
48 | - ->action('Verify your email', config('skeleton.confrim_email_url') . '/' . $notifiable->confirmation_code); |
|
49 | - } |
|
36 | + /** |
|
37 | + * Get the mail representation of the notification. |
|
38 | + * |
|
39 | + * @param mixed $notifiable |
|
40 | + * @return \Illuminate\Notifications\Messages\MailMessage |
|
41 | + */ |
|
42 | + public function toMail($notifiable) |
|
43 | + { |
|
44 | + return (new MailMessage) |
|
45 | + ->subject('Email verification') |
|
46 | + ->line('Email verification') |
|
47 | + ->line('To validate your email click on the button below') |
|
48 | + ->action('Verify your email', config('skeleton.confrim_email_url') . '/' . $notifiable->confirmation_code); |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | \ No newline at end of file |
@@ -45,6 +45,6 @@ |
||
45 | 45 | ->subject('Email verification') |
46 | 46 | ->line('Email verification') |
47 | 47 | ->line('To validate your email click on the button below') |
48 | - ->action('Verify your email', config('skeleton.confrim_email_url') . '/' . $notifiable->confirmation_code); |
|
48 | + ->action('Verify your email', config('skeleton.confrim_email_url').'/'.$notifiable->confirmation_code); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | \ No newline at end of file |
@@ -5,105 +5,105 @@ |
||
5 | 5 | |
6 | 6 | class LoginProxy |
7 | 7 | { |
8 | - private $apiConsumer; |
|
9 | - |
|
10 | - private $auth; |
|
11 | - |
|
12 | - private $db; |
|
13 | - |
|
14 | - private $request; |
|
15 | - |
|
16 | - private $userRepository; |
|
17 | - |
|
18 | - public function __construct(Application $app) |
|
19 | - { |
|
20 | - |
|
21 | - $this->userRepository = $app->make('App\Modules\Acl\Repositories\UserRepository'); |
|
22 | - $this->apiConsumer = $app->make('apiconsumer'); |
|
23 | - $this->auth = $app->make('auth'); |
|
24 | - $this->db = $app->make('db'); |
|
25 | - $this->request = $app->make('request'); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Attempt to create an access token using user credentials. |
|
30 | - * |
|
31 | - * @param array $credentials |
|
32 | - * @param boolean $adminLogin |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function login($credentials, $adminLogin = false) |
|
36 | - { |
|
37 | - $this->userRepository->login($credentials, $adminLogin); |
|
38 | - |
|
39 | - return $this->proxy('password', [ |
|
40 | - 'username' => $credentials['email'], |
|
41 | - 'password' => $credentials['password'] |
|
42 | - ]); |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Attempt to refresh the access token useing the given refresh token. |
|
47 | - * |
|
48 | - * @param string $refreshToken |
|
49 | - * @return array |
|
50 | - */ |
|
51 | - public function refreshtoken($refreshToken) |
|
52 | - { |
|
53 | - return $this->proxy('refresh_token', [ |
|
54 | - 'refresh_token' => $refreshToken |
|
55 | - ]); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Proxy a request to the OAuth server. |
|
60 | - * |
|
61 | - * @param string $grantType what type of grant type should be proxied |
|
62 | - * @param array |
|
63 | - */ |
|
64 | - public function proxy($grantType, array $data = []) |
|
65 | - { |
|
66 | - $data = array_merge($data, [ |
|
67 | - 'client_id' => config('skeleton.passport_client_id'), |
|
68 | - 'client_secret' => config('skeleton.passport_client_secret'), |
|
69 | - 'grant_type' => $grantType |
|
70 | - ]); |
|
71 | - |
|
72 | - $response = $this->apiConsumer->post('/oauth/token', $data); |
|
73 | - |
|
74 | - if ( ! $response->isSuccessful()) |
|
75 | - { |
|
76 | - if ($grantType == 'refresh_token') |
|
77 | - { |
|
78 | - \ErrorHandler::invalidRefreshToken(); |
|
79 | - } |
|
80 | - |
|
81 | - \ErrorHandler::loginFailed(); |
|
82 | - } |
|
83 | - |
|
84 | - $data = json_decode($response->getContent()); |
|
85 | - |
|
86 | - return [ |
|
87 | - 'access_token' => $data->access_token, |
|
88 | - 'refresh_token' => $data->refresh_token, |
|
89 | - 'expires_in' => $data->expires_in |
|
90 | - ]; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Logs out the user. We revoke access token and refresh token. |
|
95 | - */ |
|
96 | - public function logout() |
|
97 | - { |
|
98 | - $accessToken = $this->auth->user()->token(); |
|
99 | - |
|
100 | - $this->db |
|
101 | - ->table('oauth_refresh_tokens') |
|
102 | - ->where('access_token_id', $accessToken->id) |
|
103 | - ->update([ |
|
104 | - 'revoked' => true |
|
105 | - ]); |
|
106 | - |
|
107 | - $accessToken->revoke(); |
|
108 | - } |
|
8 | + private $apiConsumer; |
|
9 | + |
|
10 | + private $auth; |
|
11 | + |
|
12 | + private $db; |
|
13 | + |
|
14 | + private $request; |
|
15 | + |
|
16 | + private $userRepository; |
|
17 | + |
|
18 | + public function __construct(Application $app) |
|
19 | + { |
|
20 | + |
|
21 | + $this->userRepository = $app->make('App\Modules\Acl\Repositories\UserRepository'); |
|
22 | + $this->apiConsumer = $app->make('apiconsumer'); |
|
23 | + $this->auth = $app->make('auth'); |
|
24 | + $this->db = $app->make('db'); |
|
25 | + $this->request = $app->make('request'); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Attempt to create an access token using user credentials. |
|
30 | + * |
|
31 | + * @param array $credentials |
|
32 | + * @param boolean $adminLogin |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function login($credentials, $adminLogin = false) |
|
36 | + { |
|
37 | + $this->userRepository->login($credentials, $adminLogin); |
|
38 | + |
|
39 | + return $this->proxy('password', [ |
|
40 | + 'username' => $credentials['email'], |
|
41 | + 'password' => $credentials['password'] |
|
42 | + ]); |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Attempt to refresh the access token useing the given refresh token. |
|
47 | + * |
|
48 | + * @param string $refreshToken |
|
49 | + * @return array |
|
50 | + */ |
|
51 | + public function refreshtoken($refreshToken) |
|
52 | + { |
|
53 | + return $this->proxy('refresh_token', [ |
|
54 | + 'refresh_token' => $refreshToken |
|
55 | + ]); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Proxy a request to the OAuth server. |
|
60 | + * |
|
61 | + * @param string $grantType what type of grant type should be proxied |
|
62 | + * @param array |
|
63 | + */ |
|
64 | + public function proxy($grantType, array $data = []) |
|
65 | + { |
|
66 | + $data = array_merge($data, [ |
|
67 | + 'client_id' => config('skeleton.passport_client_id'), |
|
68 | + 'client_secret' => config('skeleton.passport_client_secret'), |
|
69 | + 'grant_type' => $grantType |
|
70 | + ]); |
|
71 | + |
|
72 | + $response = $this->apiConsumer->post('/oauth/token', $data); |
|
73 | + |
|
74 | + if ( ! $response->isSuccessful()) |
|
75 | + { |
|
76 | + if ($grantType == 'refresh_token') |
|
77 | + { |
|
78 | + \ErrorHandler::invalidRefreshToken(); |
|
79 | + } |
|
80 | + |
|
81 | + \ErrorHandler::loginFailed(); |
|
82 | + } |
|
83 | + |
|
84 | + $data = json_decode($response->getContent()); |
|
85 | + |
|
86 | + return [ |
|
87 | + 'access_token' => $data->access_token, |
|
88 | + 'refresh_token' => $data->refresh_token, |
|
89 | + 'expires_in' => $data->expires_in |
|
90 | + ]; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Logs out the user. We revoke access token and refresh token. |
|
95 | + */ |
|
96 | + public function logout() |
|
97 | + { |
|
98 | + $accessToken = $this->auth->user()->token(); |
|
99 | + |
|
100 | + $this->db |
|
101 | + ->table('oauth_refresh_tokens') |
|
102 | + ->where('access_token_id', $accessToken->id) |
|
103 | + ->update([ |
|
104 | + 'revoked' => true |
|
105 | + ]); |
|
106 | + |
|
107 | + $accessToken->revoke(); |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | \ No newline at end of file |
@@ -5,394 +5,394 @@ |
||
5 | 5 | |
6 | 6 | class UserRepository extends AbstractRepository |
7 | 7 | { |
8 | - /** |
|
9 | - * Return the model full namespace. |
|
10 | - * |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - protected function getModel() |
|
14 | - { |
|
15 | - return 'App\Modules\Acl\AclUser'; |
|
16 | - } |
|
17 | - |
|
18 | - |
|
19 | - /** |
|
20 | - * Return the logged in user account. |
|
21 | - * |
|
22 | - * @param array $relations |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function account($relations = []) |
|
26 | - { |
|
27 | - $permissions = []; |
|
28 | - $user = \Core::users()->find(\Auth::id(), $relations); |
|
29 | - foreach ($user->groups()->get() as $group) |
|
30 | - { |
|
31 | - $group->permissions->each(function ($permission) use (&$permissions){ |
|
32 | - $permissions[$permission->model][$permission->id] = $permission->name; |
|
33 | - }); |
|
34 | - } |
|
35 | - $user->permissions = $permissions; |
|
36 | - |
|
37 | - return $user; |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Check if the logged in user or the given user |
|
42 | - * has the given permissions on the given model. |
|
43 | - * |
|
44 | - * @param string $nameOfPermission |
|
45 | - * @param string $model |
|
46 | - * @param boolean $user |
|
47 | - * @return boolean |
|
48 | - */ |
|
49 | - public function can($nameOfPermission, $model, $user = false) |
|
50 | - { |
|
51 | - $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
|
52 | - $permissions = []; |
|
53 | - |
|
54 | - $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
55 | - $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
|
56 | - }); |
|
8 | + /** |
|
9 | + * Return the model full namespace. |
|
10 | + * |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + protected function getModel() |
|
14 | + { |
|
15 | + return 'App\Modules\Acl\AclUser'; |
|
16 | + } |
|
17 | + |
|
18 | + |
|
19 | + /** |
|
20 | + * Return the logged in user account. |
|
21 | + * |
|
22 | + * @param array $relations |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function account($relations = []) |
|
26 | + { |
|
27 | + $permissions = []; |
|
28 | + $user = \Core::users()->find(\Auth::id(), $relations); |
|
29 | + foreach ($user->groups()->get() as $group) |
|
30 | + { |
|
31 | + $group->permissions->each(function ($permission) use (&$permissions){ |
|
32 | + $permissions[$permission->model][$permission->id] = $permission->name; |
|
33 | + }); |
|
34 | + } |
|
35 | + $user->permissions = $permissions; |
|
36 | + |
|
37 | + return $user; |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Check if the logged in user or the given user |
|
42 | + * has the given permissions on the given model. |
|
43 | + * |
|
44 | + * @param string $nameOfPermission |
|
45 | + * @param string $model |
|
46 | + * @param boolean $user |
|
47 | + * @return boolean |
|
48 | + */ |
|
49 | + public function can($nameOfPermission, $model, $user = false) |
|
50 | + { |
|
51 | + $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
|
52 | + $permissions = []; |
|
53 | + |
|
54 | + $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
55 | + $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
|
56 | + }); |
|
57 | 57 | |
58 | - return in_array($nameOfPermission, $permissions); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Check if the logged in user has the given group. |
|
63 | - * |
|
64 | - * @param string $groupName |
|
65 | - * @param integer $userId |
|
66 | - * @return boolean |
|
67 | - */ |
|
68 | - public function hasGroup($groups, $user = false) |
|
69 | - { |
|
70 | - $user = $user ?: $this->find(\Auth::id()); |
|
71 | - return $user->groups->whereIn('name', $groups)->count() ? true : false; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Assign the given group ids to the given user. |
|
76 | - * |
|
77 | - * @param integer $user_id |
|
78 | - * @param array $group_ids |
|
79 | - * @return object |
|
80 | - */ |
|
81 | - public function assignGroups($user_id, $group_ids) |
|
82 | - { |
|
83 | - \DB::transaction(function () use ($user_id, $group_ids) { |
|
84 | - $user = $this->find($user_id); |
|
85 | - $user->groups()->detach(); |
|
86 | - $user->groups()->attach($group_ids); |
|
87 | - }); |
|
88 | - |
|
89 | - return $this->find($user_id); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Handle a login request to the application. |
|
95 | - * |
|
96 | - * @param array $credentials |
|
97 | - * @param boolean $adminLogin |
|
98 | - * @return object |
|
99 | - */ |
|
100 | - public function login($credentials, $adminLogin = false) |
|
101 | - { |
|
102 | - if ( ! $user = $this->first(['email' => $credentials['email']])) |
|
103 | - { |
|
104 | - \ErrorHandler::loginFailed(); |
|
105 | - } |
|
106 | - else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
107 | - { |
|
108 | - \ErrorHandler::loginFailed(); |
|
109 | - } |
|
110 | - else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
111 | - { |
|
112 | - \ErrorHandler::loginFailed(); |
|
113 | - } |
|
114 | - else if ($user->blocked) |
|
115 | - { |
|
116 | - \ErrorHandler::userIsBlocked(); |
|
117 | - } |
|
118 | - else if ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) |
|
119 | - { |
|
120 | - \ErrorHandler::emailNotConfirmed(); |
|
121 | - } |
|
122 | - |
|
123 | - return $user; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Handle a social login request of the none admin to the application. |
|
128 | - * |
|
129 | - * @param array $credentials |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - public function loginSocial($credentials) |
|
133 | - { |
|
134 | - $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token']; |
|
135 | - $user = \Socialite::driver($credentials['type'])->userFromToken($access_token); |
|
136 | - |
|
137 | - if ( ! $user->email) |
|
138 | - { |
|
139 | - \ErrorHandler::noSocialEmail(); |
|
140 | - } |
|
141 | - |
|
142 | - if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) |
|
143 | - { |
|
144 | - $data = ['email' => $user->email, 'password' => '']; |
|
145 | - return $this->register($data); |
|
146 | - } |
|
147 | - else |
|
148 | - { |
|
149 | - if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
|
150 | - { |
|
151 | - \ErrorHandler::userAlreadyRegistered(); |
|
152 | - } |
|
153 | - |
|
154 | - $loginProxy = \App::make('App\Modules\Acl\Proxy\LoginProxy'); |
|
155 | - return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0); |
|
156 | - } |
|
157 | - } |
|
58 | + return in_array($nameOfPermission, $permissions); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Check if the logged in user has the given group. |
|
63 | + * |
|
64 | + * @param string $groupName |
|
65 | + * @param integer $userId |
|
66 | + * @return boolean |
|
67 | + */ |
|
68 | + public function hasGroup($groups, $user = false) |
|
69 | + { |
|
70 | + $user = $user ?: $this->find(\Auth::id()); |
|
71 | + return $user->groups->whereIn('name', $groups)->count() ? true : false; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Assign the given group ids to the given user. |
|
76 | + * |
|
77 | + * @param integer $user_id |
|
78 | + * @param array $group_ids |
|
79 | + * @return object |
|
80 | + */ |
|
81 | + public function assignGroups($user_id, $group_ids) |
|
82 | + { |
|
83 | + \DB::transaction(function () use ($user_id, $group_ids) { |
|
84 | + $user = $this->find($user_id); |
|
85 | + $user->groups()->detach(); |
|
86 | + $user->groups()->attach($group_ids); |
|
87 | + }); |
|
88 | + |
|
89 | + return $this->find($user_id); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Handle a login request to the application. |
|
95 | + * |
|
96 | + * @param array $credentials |
|
97 | + * @param boolean $adminLogin |
|
98 | + * @return object |
|
99 | + */ |
|
100 | + public function login($credentials, $adminLogin = false) |
|
101 | + { |
|
102 | + if ( ! $user = $this->first(['email' => $credentials['email']])) |
|
103 | + { |
|
104 | + \ErrorHandler::loginFailed(); |
|
105 | + } |
|
106 | + else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
107 | + { |
|
108 | + \ErrorHandler::loginFailed(); |
|
109 | + } |
|
110 | + else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
111 | + { |
|
112 | + \ErrorHandler::loginFailed(); |
|
113 | + } |
|
114 | + else if ($user->blocked) |
|
115 | + { |
|
116 | + \ErrorHandler::userIsBlocked(); |
|
117 | + } |
|
118 | + else if ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) |
|
119 | + { |
|
120 | + \ErrorHandler::emailNotConfirmed(); |
|
121 | + } |
|
122 | + |
|
123 | + return $user; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Handle a social login request of the none admin to the application. |
|
128 | + * |
|
129 | + * @param array $credentials |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + public function loginSocial($credentials) |
|
133 | + { |
|
134 | + $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token']; |
|
135 | + $user = \Socialite::driver($credentials['type'])->userFromToken($access_token); |
|
136 | + |
|
137 | + if ( ! $user->email) |
|
138 | + { |
|
139 | + \ErrorHandler::noSocialEmail(); |
|
140 | + } |
|
141 | + |
|
142 | + if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) |
|
143 | + { |
|
144 | + $data = ['email' => $user->email, 'password' => '']; |
|
145 | + return $this->register($data); |
|
146 | + } |
|
147 | + else |
|
148 | + { |
|
149 | + if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
|
150 | + { |
|
151 | + \ErrorHandler::userAlreadyRegistered(); |
|
152 | + } |
|
153 | + |
|
154 | + $loginProxy = \App::make('App\Modules\Acl\Proxy\LoginProxy'); |
|
155 | + return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0); |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Handle a registration request. |
|
161 | - * |
|
162 | - * @param array $credentials |
|
163 | - * @return array |
|
164 | - */ |
|
165 | - public function register($credentials) |
|
166 | - { |
|
167 | - $user = $this->save($credentials); |
|
168 | - |
|
169 | - if ( ! config('skeleton.disable_confirm_email')) |
|
170 | - { |
|
171 | - $this->sendConfirmationEmail($user->email); |
|
172 | - } |
|
173 | - } |
|
159 | + /** |
|
160 | + * Handle a registration request. |
|
161 | + * |
|
162 | + * @param array $credentials |
|
163 | + * @return array |
|
164 | + */ |
|
165 | + public function register($credentials) |
|
166 | + { |
|
167 | + $user = $this->save($credentials); |
|
168 | + |
|
169 | + if ( ! config('skeleton.disable_confirm_email')) |
|
170 | + { |
|
171 | + $this->sendConfirmationEmail($user->email); |
|
172 | + } |
|
173 | + } |
|
174 | 174 | |
175 | - /** |
|
176 | - * Block the user. |
|
177 | - * |
|
178 | - * @param integer $user_id |
|
179 | - * @return object |
|
180 | - */ |
|
181 | - public function block($user_id) |
|
182 | - { |
|
183 | - if ( ! $user = $this->find($user_id)) |
|
184 | - { |
|
185 | - \ErrorHandler::notFound('user'); |
|
186 | - } |
|
187 | - if ( ! $this->hasGroup(['Admin'])) |
|
188 | - { |
|
189 | - \ErrorHandler::noPermissions(); |
|
190 | - } |
|
191 | - else if (\Auth::id() == $user_id) |
|
192 | - { |
|
193 | - \ErrorHandler::noPermissions(); |
|
194 | - } |
|
195 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
196 | - { |
|
197 | - \ErrorHandler::noPermissions(); |
|
198 | - } |
|
199 | - |
|
200 | - $user->blocked = 1; |
|
201 | - $user->save(); |
|
175 | + /** |
|
176 | + * Block the user. |
|
177 | + * |
|
178 | + * @param integer $user_id |
|
179 | + * @return object |
|
180 | + */ |
|
181 | + public function block($user_id) |
|
182 | + { |
|
183 | + if ( ! $user = $this->find($user_id)) |
|
184 | + { |
|
185 | + \ErrorHandler::notFound('user'); |
|
186 | + } |
|
187 | + if ( ! $this->hasGroup(['Admin'])) |
|
188 | + { |
|
189 | + \ErrorHandler::noPermissions(); |
|
190 | + } |
|
191 | + else if (\Auth::id() == $user_id) |
|
192 | + { |
|
193 | + \ErrorHandler::noPermissions(); |
|
194 | + } |
|
195 | + else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
196 | + { |
|
197 | + \ErrorHandler::noPermissions(); |
|
198 | + } |
|
199 | + |
|
200 | + $user->blocked = 1; |
|
201 | + $user->save(); |
|
202 | 202 | |
203 | - return $user; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Unblock the user. |
|
208 | - * |
|
209 | - * @param integer $user_id |
|
210 | - * @return object |
|
211 | - */ |
|
212 | - public function unblock($user_id) |
|
213 | - { |
|
214 | - if ( ! $this->hasGroup(['Admin'])) |
|
215 | - { |
|
216 | - \ErrorHandler::noPermissions(); |
|
217 | - } |
|
218 | - |
|
219 | - $user = $this->find($user_id); |
|
220 | - $user->blocked = 0; |
|
221 | - $user->save(); |
|
222 | - |
|
223 | - return $user; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Send a reset link to the given user. |
|
228 | - * |
|
229 | - * @param string $email |
|
230 | - * @return void |
|
231 | - */ |
|
232 | - public function sendReset($email) |
|
233 | - { |
|
234 | - if ( ! $user = $this->model->where('email', $email)->first()) |
|
235 | - { |
|
236 | - \ErrorHandler::notFound('email'); |
|
237 | - } |
|
238 | - |
|
239 | - $token = \Password::getRepository()->create($user); |
|
240 | - \Core::notifications()->notify($user, 'ResetPassword', $token); |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Reset the given user's password. |
|
245 | - * |
|
246 | - * @param array $credentials |
|
247 | - * @return array |
|
248 | - */ |
|
249 | - public function resetPassword($credentials) |
|
250 | - { |
|
251 | - $response = \Password::reset($credentials, function ($user, $password) { |
|
252 | - $user->password = $password; |
|
253 | - $user->save(); |
|
254 | - }); |
|
255 | - |
|
256 | - switch ($response) { |
|
257 | - case \Password::PASSWORD_RESET: |
|
258 | - return 'success'; |
|
203 | + return $user; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Unblock the user. |
|
208 | + * |
|
209 | + * @param integer $user_id |
|
210 | + * @return object |
|
211 | + */ |
|
212 | + public function unblock($user_id) |
|
213 | + { |
|
214 | + if ( ! $this->hasGroup(['Admin'])) |
|
215 | + { |
|
216 | + \ErrorHandler::noPermissions(); |
|
217 | + } |
|
218 | + |
|
219 | + $user = $this->find($user_id); |
|
220 | + $user->blocked = 0; |
|
221 | + $user->save(); |
|
222 | + |
|
223 | + return $user; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Send a reset link to the given user. |
|
228 | + * |
|
229 | + * @param string $email |
|
230 | + * @return void |
|
231 | + */ |
|
232 | + public function sendReset($email) |
|
233 | + { |
|
234 | + if ( ! $user = $this->model->where('email', $email)->first()) |
|
235 | + { |
|
236 | + \ErrorHandler::notFound('email'); |
|
237 | + } |
|
238 | + |
|
239 | + $token = \Password::getRepository()->create($user); |
|
240 | + \Core::notifications()->notify($user, 'ResetPassword', $token); |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Reset the given user's password. |
|
245 | + * |
|
246 | + * @param array $credentials |
|
247 | + * @return array |
|
248 | + */ |
|
249 | + public function resetPassword($credentials) |
|
250 | + { |
|
251 | + $response = \Password::reset($credentials, function ($user, $password) { |
|
252 | + $user->password = $password; |
|
253 | + $user->save(); |
|
254 | + }); |
|
255 | + |
|
256 | + switch ($response) { |
|
257 | + case \Password::PASSWORD_RESET: |
|
258 | + return 'success'; |
|
259 | 259 | |
260 | - case \Password::INVALID_TOKEN: |
|
261 | - \ErrorHandler::invalidResetToken('token'); |
|
262 | - |
|
263 | - case \Password::INVALID_PASSWORD: |
|
264 | - \ErrorHandler::invalidResetPassword('email'); |
|
265 | - |
|
266 | - case \Password::INVALID_USER: |
|
267 | - \ErrorHandler::notFound('user'); |
|
268 | - |
|
269 | - default: |
|
270 | - \ErrorHandler::generalError(); |
|
271 | - } |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * Change the logged in user password. |
|
276 | - * |
|
277 | - * @param array $credentials |
|
278 | - * @return void |
|
279 | - */ |
|
280 | - public function changePassword($credentials) |
|
281 | - { |
|
282 | - $user = \Auth::user(); |
|
283 | - if ( ! \Hash::check($credentials['old_password'], $user->password)) |
|
284 | - { |
|
285 | - \ErrorHandler::invalidOldPassword(); |
|
286 | - } |
|
287 | - |
|
288 | - $user->password = $credentials['password']; |
|
289 | - $user->save(); |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * Confirm email using the confirmation code. |
|
294 | - * |
|
295 | - * @param string $confirmationCode |
|
296 | - * @return void |
|
297 | - */ |
|
298 | - public function confirmEmail($confirmationCode) |
|
299 | - { |
|
300 | - $user = $this->first(['confirmation_code' => $confirmationCode]); |
|
301 | - $user->confirmed = 1; |
|
302 | - $user->confirmation_code = null; |
|
303 | - $user->save(); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Send the confirmation mail. |
|
308 | - * |
|
309 | - * @param string $email |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - public function sendConfirmationEmail($email) |
|
313 | - { |
|
314 | - $user = $this->first(['email' => $email]); |
|
315 | - if ($user->confirmed) |
|
316 | - { |
|
317 | - \ErrorHandler::emailAlreadyConfirmed(); |
|
318 | - } |
|
319 | - |
|
320 | - $user->confirmed = 0; |
|
321 | - $user->confirmation_code = sha1(microtime()); |
|
322 | - $user->save(); |
|
323 | - \Core::notifications()->notify($user, 'ConfirmEmail'); |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Paginate all users in the given group based on the given conditions. |
|
328 | - * |
|
329 | - * @param string $groupName |
|
330 | - * @param array $relations |
|
331 | - * @param integer $perPage |
|
332 | - * @param string $sortBy |
|
333 | - * @param boolean $desc |
|
334 | - * @return \Illuminate\Http\Response |
|
335 | - */ |
|
336 | - public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc) |
|
337 | - { |
|
338 | - unset($conditions['page']); |
|
339 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
340 | - $sort = $desc ? 'desc' : 'asc'; |
|
341 | - $model = call_user_func_array("{$this->getModel()}::with", array($relations)); |
|
342 | - |
|
343 | - $model->whereHas('groups', function($q) use ($groupName){ |
|
344 | - $q->where('name', $groupName); |
|
345 | - }); |
|
260 | + case \Password::INVALID_TOKEN: |
|
261 | + \ErrorHandler::invalidResetToken('token'); |
|
262 | + |
|
263 | + case \Password::INVALID_PASSWORD: |
|
264 | + \ErrorHandler::invalidResetPassword('email'); |
|
265 | + |
|
266 | + case \Password::INVALID_USER: |
|
267 | + \ErrorHandler::notFound('user'); |
|
268 | + |
|
269 | + default: |
|
270 | + \ErrorHandler::generalError(); |
|
271 | + } |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Change the logged in user password. |
|
276 | + * |
|
277 | + * @param array $credentials |
|
278 | + * @return void |
|
279 | + */ |
|
280 | + public function changePassword($credentials) |
|
281 | + { |
|
282 | + $user = \Auth::user(); |
|
283 | + if ( ! \Hash::check($credentials['old_password'], $user->password)) |
|
284 | + { |
|
285 | + \ErrorHandler::invalidOldPassword(); |
|
286 | + } |
|
287 | + |
|
288 | + $user->password = $credentials['password']; |
|
289 | + $user->save(); |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * Confirm email using the confirmation code. |
|
294 | + * |
|
295 | + * @param string $confirmationCode |
|
296 | + * @return void |
|
297 | + */ |
|
298 | + public function confirmEmail($confirmationCode) |
|
299 | + { |
|
300 | + $user = $this->first(['confirmation_code' => $confirmationCode]); |
|
301 | + $user->confirmed = 1; |
|
302 | + $user->confirmation_code = null; |
|
303 | + $user->save(); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Send the confirmation mail. |
|
308 | + * |
|
309 | + * @param string $email |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + public function sendConfirmationEmail($email) |
|
313 | + { |
|
314 | + $user = $this->first(['email' => $email]); |
|
315 | + if ($user->confirmed) |
|
316 | + { |
|
317 | + \ErrorHandler::emailAlreadyConfirmed(); |
|
318 | + } |
|
319 | + |
|
320 | + $user->confirmed = 0; |
|
321 | + $user->confirmation_code = sha1(microtime()); |
|
322 | + $user->save(); |
|
323 | + \Core::notifications()->notify($user, 'ConfirmEmail'); |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Paginate all users in the given group based on the given conditions. |
|
328 | + * |
|
329 | + * @param string $groupName |
|
330 | + * @param array $relations |
|
331 | + * @param integer $perPage |
|
332 | + * @param string $sortBy |
|
333 | + * @param boolean $desc |
|
334 | + * @return \Illuminate\Http\Response |
|
335 | + */ |
|
336 | + public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc) |
|
337 | + { |
|
338 | + unset($conditions['page']); |
|
339 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
340 | + $sort = $desc ? 'desc' : 'asc'; |
|
341 | + $model = call_user_func_array("{$this->getModel()}::with", array($relations)); |
|
342 | + |
|
343 | + $model->whereHas('groups', function($q) use ($groupName){ |
|
344 | + $q->where('name', $groupName); |
|
345 | + }); |
|
346 | 346 | |
347 | 347 | |
348 | - if (count($conditions['conditionValues'])) |
|
349 | - { |
|
350 | - $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
351 | - } |
|
352 | - |
|
353 | - if ($perPage) |
|
354 | - { |
|
355 | - return $model->orderBy($sortBy, $sort)->paginate($perPage); |
|
356 | - } |
|
357 | - |
|
358 | - return $model->orderBy($sortBy, $sort)->get(); |
|
359 | - } |
|
360 | - |
|
361 | - /** |
|
362 | - * Save the given data to the logged in user. |
|
363 | - * |
|
364 | - * @param array $credentials |
|
365 | - * @return void |
|
366 | - */ |
|
367 | - public function saveProfile($data) |
|
368 | - { |
|
369 | - if (array_key_exists('profile_picture', $data)) |
|
370 | - { |
|
371 | - $data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures'); |
|
372 | - } |
|
348 | + if (count($conditions['conditionValues'])) |
|
349 | + { |
|
350 | + $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
351 | + } |
|
352 | + |
|
353 | + if ($perPage) |
|
354 | + { |
|
355 | + return $model->orderBy($sortBy, $sort)->paginate($perPage); |
|
356 | + } |
|
357 | + |
|
358 | + return $model->orderBy($sortBy, $sort)->get(); |
|
359 | + } |
|
360 | + |
|
361 | + /** |
|
362 | + * Save the given data to the logged in user. |
|
363 | + * |
|
364 | + * @param array $credentials |
|
365 | + * @return void |
|
366 | + */ |
|
367 | + public function saveProfile($data) |
|
368 | + { |
|
369 | + if (array_key_exists('profile_picture', $data)) |
|
370 | + { |
|
371 | + $data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures'); |
|
372 | + } |
|
373 | 373 | |
374 | - $data['id'] = \Auth::id(); |
|
375 | - $this->save($data); |
|
376 | - } |
|
377 | - |
|
378 | - /** |
|
379 | - * Ensure access token hasn't expired or revoked. |
|
380 | - * |
|
381 | - * @param string $accessToken |
|
382 | - * @return boolean |
|
383 | - */ |
|
384 | - public function accessTokenExpiredOrRevoked($accessToken) |
|
385 | - { |
|
386 | - |
|
387 | - $accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface'); |
|
388 | - $data = new ValidationData(); |
|
389 | - $data->setCurrentTime(time()); |
|
390 | - |
|
391 | - if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) |
|
392 | - { |
|
393 | - return true; |
|
394 | - } |
|
395 | - |
|
396 | - return false; |
|
397 | - } |
|
374 | + $data['id'] = \Auth::id(); |
|
375 | + $this->save($data); |
|
376 | + } |
|
377 | + |
|
378 | + /** |
|
379 | + * Ensure access token hasn't expired or revoked. |
|
380 | + * |
|
381 | + * @param string $accessToken |
|
382 | + * @return boolean |
|
383 | + */ |
|
384 | + public function accessTokenExpiredOrRevoked($accessToken) |
|
385 | + { |
|
386 | + |
|
387 | + $accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface'); |
|
388 | + $data = new ValidationData(); |
|
389 | + $data->setCurrentTime(time()); |
|
390 | + |
|
391 | + if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) |
|
392 | + { |
|
393 | + return true; |
|
394 | + } |
|
395 | + |
|
396 | + return false; |
|
397 | + } |
|
398 | 398 | } |
@@ -102,20 +102,16 @@ discard block |
||
102 | 102 | if ( ! $user = $this->first(['email' => $credentials['email']])) |
103 | 103 | { |
104 | 104 | \ErrorHandler::loginFailed(); |
105 | - } |
|
106 | - else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
105 | + } else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
107 | 106 | { |
108 | 107 | \ErrorHandler::loginFailed(); |
109 | - } |
|
110 | - else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
108 | + } else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
111 | 109 | { |
112 | 110 | \ErrorHandler::loginFailed(); |
113 | - } |
|
114 | - else if ($user->blocked) |
|
111 | + } else if ($user->blocked) |
|
115 | 112 | { |
116 | 113 | \ErrorHandler::userIsBlocked(); |
117 | - } |
|
118 | - else if ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) |
|
114 | + } else if ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) |
|
119 | 115 | { |
120 | 116 | \ErrorHandler::emailNotConfirmed(); |
121 | 117 | } |
@@ -143,8 +139,7 @@ discard block |
||
143 | 139 | { |
144 | 140 | $data = ['email' => $user->email, 'password' => '']; |
145 | 141 | return $this->register($data); |
146 | - } |
|
147 | - else |
|
142 | + } else |
|
148 | 143 | { |
149 | 144 | if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
150 | 145 | { |
@@ -187,12 +182,10 @@ discard block |
||
187 | 182 | if ( ! $this->hasGroup(['Admin'])) |
188 | 183 | { |
189 | 184 | \ErrorHandler::noPermissions(); |
190 | - } |
|
191 | - else if (\Auth::id() == $user_id) |
|
185 | + } else if (\Auth::id() == $user_id) |
|
192 | 186 | { |
193 | 187 | \ErrorHandler::noPermissions(); |
194 | - } |
|
195 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
188 | + } else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
196 | 189 | { |
197 | 190 | \ErrorHandler::noPermissions(); |
198 | 191 | } |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | class CoreConfig |
4 | 4 | { |
5 | - public function getConfig() |
|
6 | - { |
|
7 | - return [ |
|
5 | + public function getConfig() |
|
6 | + { |
|
7 | + return [ |
|
8 | 8 | /** |
9 | 9 | * Specify what relations should be used for every model. |
10 | 10 | */ |
@@ -14,5 +14,5 @@ discard block |
||
14 | 14 | */ |
15 | 15 | 'cacheConfig' => config('skeleton.cache_config'), |
16 | 16 | ]; |
17 | - } |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -6,37 +6,37 @@ |
||
6 | 6 | |
7 | 7 | class ApiSkeletonServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Perform post-registration booting of services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->publishes([ |
|
17 | - __DIR__.'/Modules' => app_path('Modules'), |
|
18 | - __DIR__.'/../lang' => base_path('resources/lang'), |
|
19 | - __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
20 | - __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
21 | - __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
22 | - __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
23 | - ]); |
|
9 | + /** |
|
10 | + * Perform post-registration booting of services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->publishes([ |
|
17 | + __DIR__.'/Modules' => app_path('Modules'), |
|
18 | + __DIR__.'/../lang' => base_path('resources/lang'), |
|
19 | + __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
20 | + __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
21 | + __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
22 | + __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
23 | + ]); |
|
24 | 24 | |
25 | - $this->publishes([ |
|
26 | - __DIR__.'/../config/skeleton.php' => config_path('skeleton.php'), |
|
27 | - __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
28 | - ], 'config'); |
|
29 | - } |
|
25 | + $this->publishes([ |
|
26 | + __DIR__.'/../config/skeleton.php' => config_path('skeleton.php'), |
|
27 | + __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
28 | + ], 'config'); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Register any package services. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function register() |
|
37 | - { |
|
38 | - $this->mergeConfigFrom( |
|
39 | - __DIR__.'/../config/skeleton.php', 'skeleton' |
|
40 | - ); |
|
41 | - } |
|
31 | + /** |
|
32 | + * Register any package services. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function register() |
|
37 | + { |
|
38 | + $this->mergeConfigFrom( |
|
39 | + __DIR__.'/../config/skeleton.php', 'skeleton' |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | \ No newline at end of file |