@@ -171,8 +171,7 @@ |
||
| 171 | 171 | try |
| 172 | 172 | { |
| 173 | 173 | $data = (array) \Firebase\JWT\JWT::decode($token, env('JWT_SECRET'), ['HS256']); |
| 174 | - } |
|
| 175 | - catch(\RuntimeException $e) { |
|
| 174 | + } catch(\RuntimeException $e) { |
|
| 176 | 175 | $this->logout(); |
| 177 | 176 | |
| 178 | 177 | return null; |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $this->client->request('login', compact('email', 'password', 'remember')); |
| 84 | 84 | |
| 85 | - if(!$this->client->success()) { |
|
| 85 | + if (!$this->client->success()) { |
|
| 86 | 86 | return false; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if(!$this->token = $this->client->getToken()) { |
|
| 89 | + if (!$this->token = $this->client->getToken()) { |
|
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $this->client->request('unsafeLogin', compact('email', 'remember')); |
| 115 | 115 | |
| 116 | - if(!$this->client->success()) { |
|
| 116 | + if (!$this->client->success()) { |
|
| 117 | 117 | return false; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if(!$this->token = $this->client->getToken()) { |
|
| 120 | + if (!$this->token = $this->client->getToken()) { |
|
| 121 | 121 | return false; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | // If we've already retrieved the user for the current request we can just |
| 137 | 137 | // return it back immediately. We do not want to fetch the user data on |
| 138 | 138 | // every call to this method because that would be tremendously slow. |
| 139 | - if (! is_null($this->user)) { |
|
| 139 | + if (!is_null($this->user)) { |
|
| 140 | 140 | return $this->user; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $user = null; |
| 144 | 144 | |
| 145 | - if($token = $this->token()) { |
|
| 146 | - if(!$user = $this->retrieveUserFromToken($token)) { |
|
| 147 | - if(!$user = $this->syncInstantly()) { |
|
| 145 | + if ($token = $this->token()) { |
|
| 146 | + if (!$user = $this->retrieveUserFromToken($token)) { |
|
| 147 | + if (!$user = $this->syncInstantly()) { |
|
| 148 | 148 | $this->logout(); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function token() |
| 162 | 162 | { |
| 163 | - if($this->token) { |
|
| 163 | + if ($this->token) { |
|
| 164 | 164 | return $this->token; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -209,13 +209,13 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | $data = (array) \Firebase\JWT\JWT::decode($token, env('JWT_SECRET'), ['HS256']); |
| 211 | 211 | } |
| 212 | - catch(\RuntimeException $e) { |
|
| 212 | + catch (\RuntimeException $e) { |
|
| 213 | 213 | $this->logout(); |
| 214 | 214 | |
| 215 | 215 | return null; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if(!$userId = array_get($data, 'userId')) { |
|
| 218 | + if (!$userId = array_get($data, 'userId')) { |
|
| 219 | 219 | return null; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | private function syncInstantly() |
| 233 | 233 | { |
| 234 | - if($user = $this->authService->retrieveByToken()) { |
|
| 234 | + if ($user = $this->authService->retrieveByToken()) { |
|
| 235 | 235 | return $this->authService->handle('sync.create', ['remote' => $user]); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -311,7 +311,7 @@ |
||
| 311 | 311 | $this->formatted = $decoded; |
| 312 | 312 | |
| 313 | 313 | if($this->success()) { |
| 314 | - return $this->formatted; |
|
| 314 | + return $this->formatted; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | $message = array_get($this->formatted, 'message'); |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected function boot() |
| 63 | 63 | { |
| 64 | - if(!$publicKey = $this->credential('public')) { |
|
| 64 | + if (!$publicKey = $this->credential('public')) { |
|
| 65 | 65 | throw new \InvalidArgumentException('Public key must be defined'); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if(!$secretKey = $this->credential('secret')) { |
|
| 68 | + if (!$secretKey = $this->credential('secret')) { |
|
| 69 | 69 | throw new \InvalidArgumentException('Secret key must be defined'); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if(!$this->client) { |
|
| 72 | + if (!$this->client) { |
|
| 73 | 73 | $handler = new \GuzzleHttp\HandlerStack(); |
| 74 | 74 | $handler->setHandler(new \GuzzleHttp\Handler\CurlHandler()); |
| 75 | 75 | $handler->push($this->bearerTokenHeader()); |
@@ -243,11 +243,11 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public function request(string $name, array $parameters = []): array |
| 245 | 245 | { |
| 246 | - if(!$this->hasRequest($name)) { |
|
| 246 | + if (!$this->hasRequest($name)) { |
|
| 247 | 247 | throw new \InvalidArgumentException("Request `{$name}` is not supported"); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - if(!method_exists($this, $name)) { |
|
| 250 | + if (!method_exists($this, $name)) { |
|
| 251 | 251 | throw new \InvalidArgumentException("Request `{$name}` listed but is not implemented"); |
| 252 | 252 | } |
| 253 | 253 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function success(bool $withStatus = false): bool |
| 279 | 279 | { |
| 280 | - if(!$this->response || $this->response->getStatusCode() !== 200) { |
|
| 280 | + if (!$this->response || $this->response->getStatusCode() !== 200) { |
|
| 281 | 281 | return false; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | $this->formatted = $decoded; |
| 343 | 343 | |
| 344 | - if($this->success()) { |
|
| 344 | + if ($this->success()) { |
|
| 345 | 345 | return $this->formatted; |
| 346 | 346 | } |
| 347 | 347 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | private function bearerToken() |
| 371 | 371 | { |
| 372 | - if(!$token = app('auth')->token()) { |
|
| 372 | + if (!$token = app('auth')->token()) { |
|
| 373 | 373 | return null; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | public function bearerTokenHeader(): \Closure |
| 385 | 385 | { |
| 386 | 386 | return function(callable $handler) { |
| 387 | - return function (\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) { |
|
| 387 | + return function(\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) { |
|
| 388 | 388 | $request = $request->withHeader('Authorization', $this->bearerToken()); |
| 389 | 389 | |
| 390 | 390 | return $handler($request, $options); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function loadConsoleCommands() |
| 75 | 75 | { |
| 76 | - if(!$this->app->runningInConsole()) { |
|
| 76 | + if (!$this->app->runningInConsole()) { |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | protected function loadGuards() |
| 92 | 92 | { |
| 93 | 93 | // Skip loading guards if an application running in the console |
| 94 | - if($this->app->runningInConsole()) { |
|
| 94 | + if ($this->app->runningInConsole()) { |
|
| 95 | 95 | return; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $this->app['auth']->guard('authService') |
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - if(!$this->enabled()) { |
|
| 102 | + if (!$this->enabled()) { |
|
| 103 | 103 | $this->app['authService']->setFallbackGuard( |
| 104 | 104 | $this->app['auth']->guard('fallback') |
| 105 | 105 | ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | }); |
| 137 | 137 | |
| 138 | 138 | // Register the fallback driver if service is disabled |
| 139 | - if(!$this->enabled()) { |
|
| 139 | + if (!$this->enabled()) { |
|
| 140 | 140 | $this->app['auth']->shouldUse('fallback'); |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | $messages = []; |
| 47 | 47 | |
| 48 | 48 | foreach (json_decode($message, true) as $property => $attributeMessages) { |
| 49 | - if(in_array($property, static::$attributeHides)) { |
|
| 49 | + if (in_array($property, static::$attributeHides)) { |
|
| 50 | 50 | continue; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function showResetForm(string $token, string $email) |
| 30 | 30 | { |
| 31 | - if(!$email = AuthService::validatePasswordResetToken($token, $email)) { |
|
| 31 | + if (!$email = AuthService::validatePasswordResetToken($token, $email)) { |
|
| 32 | 32 | throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException(); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $this->validate($request, $this->rules(), $this->validationErrorMessages()); |
| 50 | 50 | |
| 51 | - if(AuthService::resetPassword( |
|
| 51 | + if (AuthService::resetPassword( |
|
| 52 | 52 | $request->input('token'), |
| 53 | 53 | $email = $request->input('email'), |
| 54 | 54 | $password = $request->input('password'), |
| 55 | 55 | $request->input('password_confirmation') |
| 56 | 56 | )) { |
| 57 | - if(AuthService::login($email, $password)) { |
|
| 57 | + if (AuthService::login($email, $password)) { |
|
| 58 | 58 | return $this->sendResetResponse(PasswordBroker::PASSWORD_RESET); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | ->newQuery() |
| 75 | 75 | ->get(); |
| 76 | 76 | |
| 77 | - if($users->isEmpty()) { |
|
| 77 | + if ($users->isEmpty()) { |
|
| 78 | 78 | $this->info('No users found.'); |
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if(!$this->confirm('There are ' . $users->count() . ' users to sync. Continue?')) { |
|
| 82 | + if (!$this->confirm('There are ' . $users->count() . ' users to sync. Continue?')) { |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $this->writeStats('Remote affection', array_keys($remoteStats), array_values($remoteStats)); |
| 95 | 95 | |
| 96 | - if(!count($difference)) { |
|
| 96 | + if (!count($difference)) { |
|
| 97 | 97 | $this->info('There are no changes to apply locally.'); |
| 98 | 98 | } |
| 99 | 99 | else { |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $email = $user->getEmail(); |
| 188 | 188 | |
| 189 | 189 | // If a user already exists, skip the process |
| 190 | - if(Auth::getProvider()->retrieveByCredentials(['email' => $email])) { |
|
| 190 | + if (Auth::getProvider()->retrieveByCredentials(['email' => $email])) { |
|
| 191 | 191 | $this->warn("User with email {$email} already exists, unable to create"); |
| 192 | 192 | |
| 193 | 193 | return; |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | $email = $user->getEmail(); |
| 209 | 209 | |
| 210 | 210 | // If a user doesn't exist, skip the process |
| 211 | - if(!$model = Auth::getProvider()->retrieveByCredentials(['email' => $email])) { |
|
| 211 | + if (!$model = Auth::getProvider()->retrieveByCredentials(['email' => $email])) { |
|
| 212 | 212 | $this->warn("User with email {$email} doesn't exist, unable to update"); |
| 213 | 213 | |
| 214 | 214 | return; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if(!$this->passwords) { |
|
| 217 | + if (!$this->passwords) { |
|
| 218 | 218 | $user->resetPassword(); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $email = $user->getEmail(); |
| 237 | 237 | |
| 238 | 238 | // If a user doesn't exist, skip the process |
| 239 | - if(!$model = Auth::getProvider()->retrieveByCredentials(['email' => $email])) { |
|
| 239 | + if (!$model = Auth::getProvider()->retrieveByCredentials(['email' => $email])) { |
|
| 240 | 240 | $this->warn("User with email {$email} doesn't exist, unable to delete"); |
| 241 | 241 | |
| 242 | 242 | return; |
@@ -95,8 +95,7 @@ |
||
| 95 | 95 | |
| 96 | 96 | if(!count($difference)) { |
| 97 | 97 | $this->info('There are no changes to apply locally.'); |
| 98 | - } |
|
| 99 | - else { |
|
| 98 | + } else { |
|
| 100 | 99 | $this->info('Remote changes detected, applying...'); |
| 101 | 100 | |
| 102 | 101 | $localStats = $this->applyDifference($difference); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function login(string $email, string $password, bool $remember = false) |
| 83 | 83 | { |
| 84 | - if($this->disabled()) { |
|
| 84 | + if ($this->disabled()) { |
|
| 85 | 85 | return $this->handleFallback('login', compact('email', 'password', 'remember')); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function unsafeLogin(string $email, bool $remember = false) |
| 105 | 105 | { |
| 106 | - if($this->disabled()) { |
|
| 106 | + if ($this->disabled()) { |
|
| 107 | 107 | return $this->handleFallback('unsafeLogin', compact('email', 'remember')); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function logout() |
| 121 | 121 | { |
| 122 | - if($this->disabled()) { |
|
| 122 | + if ($this->disabled()) { |
|
| 123 | 123 | return $this->handleFallback('logout'); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function register(int $userId, string $name, string $email, string $password, string $country) |
| 143 | 143 | { |
| 144 | - if($this->disabled()) { |
|
| 144 | + if ($this->disabled()) { |
|
| 145 | 145 | return []; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function forgot(string $email) |
| 161 | 161 | { |
| 162 | - if($this->disabled()) { |
|
| 162 | + if ($this->disabled()) { |
|
| 163 | 163 | return $this->handleFallback('forgot', compact('email')); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function validatePasswordResetToken(string $token, string $email) |
| 182 | 182 | { |
| 183 | - if($this->disabled()) { |
|
| 183 | + if ($this->disabled()) { |
|
| 184 | 184 | return $this->handleFallback('validateReset', compact('token', 'email')); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $response = $this->client->request('validateReset', compact('token', 'email')); |
| 188 | 188 | |
| 189 | - if(!$this->client->success(true)) { |
|
| 189 | + if (!$this->client->success(true)) { |
|
| 190 | 190 | return false; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -209,13 +209,13 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | $parameters = compact('token', 'email', 'password', 'confirmation'); |
| 211 | 211 | |
| 212 | - if($this->disabled()) { |
|
| 212 | + if ($this->disabled()) { |
|
| 213 | 213 | return $this->handleFallback('resetPassword', $parameters); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $response = $this->client->request('reset', $parameters); |
| 217 | 217 | |
| 218 | - if(!$this->client->success(true)) { |
|
| 218 | + if (!$this->client->success(true)) { |
|
| 219 | 219 | return false; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public function update(int $id, ?string $name, ?string $email, ?string $password) |
| 236 | 236 | { |
| 237 | - if($this->disabled()) { |
|
| 237 | + if ($this->disabled()) { |
|
| 238 | 238 | return false; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | $response = $this->client->request('update', compact('id', 'attributes')); |
| 244 | 244 | |
| 245 | - if(!$this->client->success(true)) { |
|
| 245 | + if (!$this->client->success(true)) { |
|
| 246 | 246 | return false; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -256,18 +256,18 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function retrieveByToken() |
| 258 | 258 | { |
| 259 | - if($this->disabled()) { |
|
| 259 | + if ($this->disabled()) { |
|
| 260 | 260 | return null; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | try { |
| 264 | 264 | $response = $this->client->request('me'); |
| 265 | 265 | } |
| 266 | - catch(\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) { |
|
| 266 | + catch (\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) { |
|
| 267 | 267 | return null; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if(!$this->client->success(true)) { |
|
| 270 | + if (!$this->client->success(true)) { |
|
| 271 | 271 | return null; |
| 272 | 272 | } |
| 273 | 273 | |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | { |
| 302 | 302 | $handler = camel_case(str_replace('.', ' ', $key)); |
| 303 | 303 | |
| 304 | - if(!method_exists($this->handlersContainer, $handler)) { |
|
| 304 | + if (!method_exists($this->handlersContainer, $handler)) { |
|
| 305 | 305 | throw new \InvalidArgumentException("Handler `{$handler}` cannot be found"); |
| 306 | 306 | } |
| 307 | 307 | |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | try { |
| 347 | 347 | $output = $callback(); |
| 348 | 348 | } |
| 349 | - catch(\Exception $e) { |
|
| 349 | + catch (\Exception $e) { |
|
| 350 | 350 | DB::rollBack(); |
| 351 | 351 | |
| 352 | - if(is_null($fallback)) { |
|
| 352 | + if (is_null($fallback)) { |
|
| 353 | 353 | throw $e; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -262,8 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | try { |
| 264 | 264 | $response = $this->client->request('me'); |
| 265 | - } |
|
| 266 | - catch(\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) { |
|
| 265 | + } catch(\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) { |
|
| 267 | 266 | return null; |
| 268 | 267 | } |
| 269 | 268 | |
@@ -345,8 +344,7 @@ discard block |
||
| 345 | 344 | |
| 346 | 345 | try { |
| 347 | 346 | $output = $callback(); |
| 348 | - } |
|
| 349 | - catch(\Exception $e) { |
|
| 347 | + } catch(\Exception $e) { |
|
| 350 | 348 | DB::rollBack(); |
| 351 | 349 | |
| 352 | 350 | if(is_null($fallback)) { |