@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /** |
|
6 | - * Here goes your notification messages. |
|
7 | - */ |
|
5 | + /** |
|
6 | + * Here goes your notification messages. |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | ]; |
10 | 10 | \ 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('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('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('confrim_email_url') . '/' . $notifiable->confirmation_code)); |
|
48 | + ->action('Verify your email', config('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('passport_client_id'), |
|
68 | - 'client_secret' => config('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('passport_client_id'), |
|
68 | + 'client_secret' => config('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 |
@@ -6,35 +6,35 @@ |
||
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' => base_path('app/Exceptions/Handler.php'), |
|
20 | - __DIR__.'/../files/auth.php' => base_path('config/auth.php'), |
|
21 | - __DIR__.'/../files/AuthServiceProvider.php' => base_path('app/Providers/AuthServiceProvider.php'), |
|
22 | - __DIR__.'/../files/BroadcastServiceProvider.php' => base_path('app/Providers/BroadcastServiceProvider.php'), |
|
23 | - __DIR__.'/../files/Kernel.php' => base_path('app/Console/Kernel.php'), |
|
24 | - ]); |
|
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' => base_path('app/Exceptions/Handler.php'), |
|
20 | + __DIR__.'/../files/auth.php' => base_path('config/auth.php'), |
|
21 | + __DIR__.'/../files/AuthServiceProvider.php' => base_path('app/Providers/AuthServiceProvider.php'), |
|
22 | + __DIR__.'/../files/BroadcastServiceProvider.php' => base_path('app/Providers/BroadcastServiceProvider.php'), |
|
23 | + __DIR__.'/../files/Kernel.php' => base_path('app/Console/Kernel.php'), |
|
24 | + ]); |
|
25 | 25 | |
26 | - $this->publishes([ |
|
27 | - __DIR__.'/../config/skeleton.php' => config_path('skeleton.php'), |
|
28 | - ], 'config'); |
|
29 | - } |
|
26 | + $this->publishes([ |
|
27 | + __DIR__.'/../config/skeleton.php' => config_path('skeleton.php'), |
|
28 | + ], 'config'); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Register any package services. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function register() |
|
37 | - { |
|
38 | - // |
|
39 | - } |
|
31 | + /** |
|
32 | + * Register any package services. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function register() |
|
37 | + { |
|
38 | + // |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -8,31 +8,31 @@ |
||
8 | 8 | |
9 | 9 | class AuthServiceProvider extends ServiceProvider |
10 | 10 | { |
11 | - /** |
|
12 | - * The policy mappings for the application. |
|
13 | - * |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $policies = [ |
|
17 | - 'App\Model' => 'App\Policies\ModelPolicy', |
|
18 | - ]; |
|
11 | + /** |
|
12 | + * The policy mappings for the application. |
|
13 | + * |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $policies = [ |
|
17 | + 'App\Model' => 'App\Policies\ModelPolicy', |
|
18 | + ]; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Register any authentication / authorization services. |
|
22 | - * |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function boot() |
|
26 | - { |
|
27 | - $this->registerPolicies(); |
|
20 | + /** |
|
21 | + * Register any authentication / authorization services. |
|
22 | + * |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function boot() |
|
26 | + { |
|
27 | + $this->registerPolicies(); |
|
28 | 28 | |
29 | - Passport::routes(function ($router) { |
|
30 | - $router->forAuthorization(); |
|
31 | - $router->forAccessTokens(); |
|
32 | - $router->forPersonalAccessTokens(); |
|
33 | - $router->forTransientTokens(); |
|
34 | - }); |
|
35 | - Passport::tokensExpireIn(\Carbon\Carbon::now()->addMinutes(10)); |
|
36 | - Passport::refreshTokensExpireIn(\Carbon\Carbon::now()->addDays(10)); |
|
37 | - } |
|
29 | + Passport::routes(function ($router) { |
|
30 | + $router->forAuthorization(); |
|
31 | + $router->forAccessTokens(); |
|
32 | + $router->forPersonalAccessTokens(); |
|
33 | + $router->forTransientTokens(); |
|
34 | + }); |
|
35 | + Passport::tokensExpireIn(\Carbon\Carbon::now()->addMinutes(10)); |
|
36 | + Passport::refreshTokensExpireIn(\Carbon\Carbon::now()->addDays(10)); |
|
37 | + } |
|
38 | 38 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | $this->registerPolicies(); |
28 | 28 | |
29 | - Passport::routes(function ($router) { |
|
29 | + Passport::routes(function($router) { |
|
30 | 30 | $router->forAuthorization(); |
31 | 31 | $router->forAccessTokens(); |
32 | 32 | $router->forPersonalAccessTokens(); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Authentication Defaults |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | - 'defaults' => [ |
|
17 | - 'guard' => 'web', |
|
18 | - 'passwords' => 'users', |
|
19 | - ], |
|
16 | + 'defaults' => [ |
|
17 | + 'guard' => 'web', |
|
18 | + 'passwords' => 'users', |
|
19 | + ], |
|
20 | 20 | |
21 | - /* |
|
21 | + /* |
|
22 | 22 | |-------------------------------------------------------------------------- |
23 | 23 | | Authentication Guards |
24 | 24 | |-------------------------------------------------------------------------- |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | | |
36 | 36 | */ |
37 | 37 | |
38 | - 'guards' => [ |
|
39 | - 'web' => [ |
|
40 | - 'driver' => 'session', |
|
41 | - 'provider' => 'users', |
|
42 | - ], |
|
38 | + 'guards' => [ |
|
39 | + 'web' => [ |
|
40 | + 'driver' => 'session', |
|
41 | + 'provider' => 'users', |
|
42 | + ], |
|
43 | 43 | |
44 | - 'api' => [ |
|
45 | - 'driver' => 'passport', |
|
46 | - 'provider' => 'users', |
|
47 | - ], |
|
48 | - ], |
|
44 | + 'api' => [ |
|
45 | + 'driver' => 'passport', |
|
46 | + 'provider' => 'users', |
|
47 | + ], |
|
48 | + ], |
|
49 | 49 | |
50 | - /* |
|
50 | + /* |
|
51 | 51 | |-------------------------------------------------------------------------- |
52 | 52 | | User Providers |
53 | 53 | |-------------------------------------------------------------------------- |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | | |
65 | 65 | */ |
66 | 66 | |
67 | - 'providers' => [ |
|
68 | - 'users' => [ |
|
69 | - 'driver' => 'eloquent', |
|
70 | - 'model' => App\Modules\Acl\AclUser::class, |
|
71 | - ], |
|
67 | + 'providers' => [ |
|
68 | + 'users' => [ |
|
69 | + 'driver' => 'eloquent', |
|
70 | + 'model' => App\Modules\Acl\AclUser::class, |
|
71 | + ], |
|
72 | 72 | |
73 | - // 'users' => [ |
|
74 | - // 'driver' => 'database', |
|
75 | - // 'table' => 'users', |
|
76 | - // ], |
|
77 | - ], |
|
73 | + // 'users' => [ |
|
74 | + // 'driver' => 'database', |
|
75 | + // 'table' => 'users', |
|
76 | + // ], |
|
77 | + ], |
|
78 | 78 | |
79 | - /* |
|
79 | + /* |
|
80 | 80 | |-------------------------------------------------------------------------- |
81 | 81 | | Resetting Passwords |
82 | 82 | |-------------------------------------------------------------------------- |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | | |
92 | 92 | */ |
93 | 93 | |
94 | - 'passwords' => [ |
|
95 | - 'users' => [ |
|
96 | - 'provider' => 'users', |
|
97 | - 'table' => 'password_resets', |
|
98 | - 'expire' => 60, |
|
99 | - ], |
|
100 | - ], |
|
94 | + 'passwords' => [ |
|
95 | + 'users' => [ |
|
96 | + 'provider' => 'users', |
|
97 | + 'table' => 'password_resets', |
|
98 | + 'expire' => 60, |
|
99 | + ], |
|
100 | + ], |
|
101 | 101 | |
102 | 102 | ]; |
@@ -7,81 +7,81 @@ |
||
7 | 7 | |
8 | 8 | class Handler extends ExceptionHandler |
9 | 9 | { |
10 | - /** |
|
11 | - * A list of the exception types that are not reported. |
|
12 | - * |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected $dontReport = [ |
|
16 | - \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
17 | - ]; |
|
10 | + /** |
|
11 | + * A list of the exception types that are not reported. |
|
12 | + * |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected $dontReport = [ |
|
16 | + \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
17 | + ]; |
|
18 | 18 | |
19 | - /** |
|
20 | - * A list of the inputs that are never flashed for validation exceptions. |
|
21 | - * |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $dontFlash = [ |
|
25 | - 'password', |
|
26 | - 'password_confirmation', |
|
27 | - ]; |
|
19 | + /** |
|
20 | + * A list of the inputs that are never flashed for validation exceptions. |
|
21 | + * |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $dontFlash = [ |
|
25 | + 'password', |
|
26 | + 'password_confirmation', |
|
27 | + ]; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Report or log an exception. |
|
31 | - * |
|
32 | - * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
33 | - * |
|
34 | - * @param \Exception $exception |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - public function report(Exception $exception) |
|
38 | - { |
|
39 | - parent::report($exception); |
|
40 | - } |
|
29 | + /** |
|
30 | + * Report or log an exception. |
|
31 | + * |
|
32 | + * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
33 | + * |
|
34 | + * @param \Exception $exception |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + public function report(Exception $exception) |
|
38 | + { |
|
39 | + parent::report($exception); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Render an exception into an HTTP response. |
|
44 | - * |
|
45 | - * @param \Illuminate\Http\Request $request |
|
46 | - * @param \Exception $exception |
|
47 | - * @return \Illuminate\Http\Response |
|
48 | - */ |
|
49 | - public function render($request, Exception $exception) |
|
50 | - { |
|
51 | - if ($request->wantsJson()) |
|
52 | - { |
|
53 | - if ($exception instanceof \Illuminate\Auth\AuthenticationException) |
|
54 | - { |
|
55 | - \ErrorHandler::unAuthorized(); |
|
56 | - } |
|
57 | - if ($exception instanceof \Illuminate\Database\QueryException) |
|
58 | - { |
|
59 | - \ErrorHandler::dbQueryError(); |
|
60 | - } |
|
61 | - else if ($exception instanceof \predis\connection\connectionexception) |
|
62 | - { |
|
63 | - \ErrorHandler::redisNotRunning(); |
|
64 | - } |
|
65 | - else if ($exception instanceof \GuzzleHttp\Exception\ClientException) |
|
66 | - { |
|
67 | - \ErrorHandler::connectionError(); |
|
68 | - } |
|
69 | - else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) |
|
70 | - { |
|
71 | - return \Response::json($exception->getMessage(), $exception->getStatusCode()); |
|
72 | - } |
|
73 | - else if ($exception instanceof \Illuminate\Validation\ValidationException) |
|
74 | - { |
|
75 | - return \Response::json($exception->errors(), 422); |
|
76 | - } |
|
77 | - else if ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) |
|
78 | - { |
|
79 | - return parent::render($request, $exception); |
|
80 | - } |
|
81 | - } |
|
82 | - else |
|
83 | - { |
|
84 | - return parent::render($request, $exception); |
|
85 | - } |
|
86 | - } |
|
42 | + /** |
|
43 | + * Render an exception into an HTTP response. |
|
44 | + * |
|
45 | + * @param \Illuminate\Http\Request $request |
|
46 | + * @param \Exception $exception |
|
47 | + * @return \Illuminate\Http\Response |
|
48 | + */ |
|
49 | + public function render($request, Exception $exception) |
|
50 | + { |
|
51 | + if ($request->wantsJson()) |
|
52 | + { |
|
53 | + if ($exception instanceof \Illuminate\Auth\AuthenticationException) |
|
54 | + { |
|
55 | + \ErrorHandler::unAuthorized(); |
|
56 | + } |
|
57 | + if ($exception instanceof \Illuminate\Database\QueryException) |
|
58 | + { |
|
59 | + \ErrorHandler::dbQueryError(); |
|
60 | + } |
|
61 | + else if ($exception instanceof \predis\connection\connectionexception) |
|
62 | + { |
|
63 | + \ErrorHandler::redisNotRunning(); |
|
64 | + } |
|
65 | + else if ($exception instanceof \GuzzleHttp\Exception\ClientException) |
|
66 | + { |
|
67 | + \ErrorHandler::connectionError(); |
|
68 | + } |
|
69 | + else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) |
|
70 | + { |
|
71 | + return \Response::json($exception->getMessage(), $exception->getStatusCode()); |
|
72 | + } |
|
73 | + else if ($exception instanceof \Illuminate\Validation\ValidationException) |
|
74 | + { |
|
75 | + return \Response::json($exception->errors(), 422); |
|
76 | + } |
|
77 | + else if ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) |
|
78 | + { |
|
79 | + return parent::render($request, $exception); |
|
80 | + } |
|
81 | + } |
|
82 | + else |
|
83 | + { |
|
84 | + return parent::render($request, $exception); |
|
85 | + } |
|
86 | + } |
|
87 | 87 | } |
@@ -57,29 +57,23 @@ |
||
57 | 57 | if ($exception instanceof \Illuminate\Database\QueryException) |
58 | 58 | { |
59 | 59 | \ErrorHandler::dbQueryError(); |
60 | - } |
|
61 | - else if ($exception instanceof \predis\connection\connectionexception) |
|
60 | + } else if ($exception instanceof \predis\connection\connectionexception) |
|
62 | 61 | { |
63 | 62 | \ErrorHandler::redisNotRunning(); |
64 | - } |
|
65 | - else if ($exception instanceof \GuzzleHttp\Exception\ClientException) |
|
63 | + } else if ($exception instanceof \GuzzleHttp\Exception\ClientException) |
|
66 | 64 | { |
67 | 65 | \ErrorHandler::connectionError(); |
68 | - } |
|
69 | - else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) |
|
66 | + } else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) |
|
70 | 67 | { |
71 | 68 | return \Response::json($exception->getMessage(), $exception->getStatusCode()); |
72 | - } |
|
73 | - else if ($exception instanceof \Illuminate\Validation\ValidationException) |
|
69 | + } else if ($exception instanceof \Illuminate\Validation\ValidationException) |
|
74 | 70 | { |
75 | 71 | return \Response::json($exception->errors(), 422); |
76 | - } |
|
77 | - else if ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) |
|
72 | + } else if ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) |
|
78 | 73 | { |
79 | 74 | return parent::render($request, $exception); |
80 | 75 | } |
81 | - } |
|
82 | - else |
|
76 | + } else |
|
83 | 77 | { |
84 | 78 | return parent::render($request, $exception); |
85 | 79 | } |
@@ -7,15 +7,15 @@ |
||
7 | 7 | |
8 | 8 | class BroadcastServiceProvider extends ServiceProvider |
9 | 9 | { |
10 | - /** |
|
11 | - * Bootstrap any application services. |
|
12 | - * |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function boot() |
|
16 | - { |
|
17 | - Broadcast::routes(['middleware' => ['auth:api']]); |
|
10 | + /** |
|
11 | + * Bootstrap any application services. |
|
12 | + * |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function boot() |
|
16 | + { |
|
17 | + Broadcast::routes(['middleware' => ['auth:api']]); |
|
18 | 18 | |
19 | - require base_path('routes/channels.php'); |
|
20 | - } |
|
19 | + require base_path('routes/channels.php'); |
|
20 | + } |
|
21 | 21 | } |
@@ -9,38 +9,38 @@ |
||
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 | - UpdateTeachersWorkingHoursCommand::class |
|
21 | - ]; |
|
12 | + /** |
|
13 | + * The Artisan commands provided by your application. |
|
14 | + * |
|
15 | + * @var array |
|
16 | + */ |
|
17 | + protected $commands = [ |
|
18 | + GenerateDoc::class, |
|
19 | + MakeNotificationsCommand::class, |
|
20 | + UpdateTeachersWorkingHoursCommand::class |
|
21 | + ]; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Define the application's command schedule. |
|
25 | - * |
|
26 | - * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - protected function schedule(Schedule $schedule) |
|
30 | - { |
|
31 | - // $schedule->command('inspire') |
|
32 | - // ->hourly(); |
|
33 | - } |
|
23 | + /** |
|
24 | + * Define the application's command schedule. |
|
25 | + * |
|
26 | + * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + protected function schedule(Schedule $schedule) |
|
30 | + { |
|
31 | + // $schedule->command('inspire') |
|
32 | + // ->hourly(); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Register the commands for the application. |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - protected function commands() |
|
41 | - { |
|
42 | - $this->load(__DIR__.'/Commands'); |
|
35 | + /** |
|
36 | + * Register the commands for the application. |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + protected function commands() |
|
41 | + { |
|
42 | + $this->load(__DIR__.'/Commands'); |
|
43 | 43 | |
44 | - require base_path('routes/console.php'); |
|
45 | - } |
|
44 | + require base_path('routes/console.php'); |
|
45 | + } |
|
46 | 46 | } |