| @@ -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,13 +136,13 @@ 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()) { | |
| 145 | +        if ($token = $this->token()) { | |
| 146 | 146 | $user = $this->retrieveUserFromToken($token); | 
| 147 | 147 | } | 
| 148 | 148 | |
| @@ -156,7 +156,7 @@ discard block | ||
| 156 | 156 | */ | 
| 157 | 157 | public function token() | 
| 158 | 158 |      { | 
| 159 | -        if($this->token) { | |
| 159 | +        if ($this->token) { | |
| 160 | 160 | return $this->token; | 
| 161 | 161 | } | 
| 162 | 162 | |
| @@ -205,13 +205,13 @@ discard block | ||
| 205 | 205 |          { | 
| 206 | 206 |              $data = (array) \Firebase\JWT\JWT::decode($token, env('JWT_SECRET'), ['HS256']); | 
| 207 | 207 | } | 
| 208 | -        catch(\RuntimeException $e) { | |
| 208 | +        catch (\RuntimeException $e) { | |
| 209 | 209 | $this->logout(); | 
| 210 | 210 | |
| 211 | 211 | return null; | 
| 212 | 212 | } | 
| 213 | 213 | |
| 214 | -        if(!$userId = array_get($data, 'userId')) { | |
| 214 | +        if (!$userId = array_get($data, 'userId')) { | |
| 215 | 215 | return null; | 
| 216 | 216 | } | 
| 217 | 217 | |
| @@ -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 | } | 
| @@ -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)) { | 
| @@ -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 | |
| @@ -235,7 +235,7 @@ discard block | ||
| 235 | 235 | */ | 
| 236 | 236 | public function update(int $id, ?string $name, ?string $email, ?string $password, ?string $country) | 
| 237 | 237 |      { | 
| 238 | -        if($this->disabled()) { | |
| 238 | +        if ($this->disabled()) { | |
| 239 | 239 | return false; | 
| 240 | 240 | } | 
| 241 | 241 | |
| @@ -243,7 +243,7 @@ discard block | ||
| 243 | 243 | |
| 244 | 244 |          $response = $this->client->request('update', compact('id', 'attributes')); | 
| 245 | 245 | |
| 246 | -        if(!$this->client->success(true)) { | |
| 246 | +        if (!$this->client->success(true)) { | |
| 247 | 247 | return false; | 
| 248 | 248 | } | 
| 249 | 249 | |
| @@ -259,13 +259,13 @@ discard block | ||
| 259 | 259 | */ | 
| 260 | 260 | public function delete(int $id) | 
| 261 | 261 |      { | 
| 262 | -        if($this->disabled()) { | |
| 262 | +        if ($this->disabled()) { | |
| 263 | 263 | return false; | 
| 264 | 264 | } | 
| 265 | 265 | |
| 266 | 266 |          $response = $this->client->request('delete', compact('id')); | 
| 267 | 267 | |
| 268 | -        if(!$this->client->success(true)) { | |
| 268 | +        if (!$this->client->success(true)) { | |
| 269 | 269 | return false; | 
| 270 | 270 | } | 
| 271 | 271 | |
| @@ -281,13 +281,13 @@ discard block | ||
| 281 | 281 | */ | 
| 282 | 282 | public function restore(int $id) | 
| 283 | 283 |      { | 
| 284 | -        if($this->disabled()) { | |
| 284 | +        if ($this->disabled()) { | |
| 285 | 285 | return false; | 
| 286 | 286 | } | 
| 287 | 287 | |
| 288 | 288 |          $response = $this->client->request('restore', compact('id')); | 
| 289 | 289 | |
| 290 | -        if(!$this->client->success(true)) { | |
| 290 | +        if (!$this->client->success(true)) { | |
| 291 | 291 | return false; | 
| 292 | 292 | } | 
| 293 | 293 | |
| @@ -301,18 +301,18 @@ discard block | ||
| 301 | 301 | */ | 
| 302 | 302 | public function retrieveByToken() | 
| 303 | 303 |      { | 
| 304 | -        if($this->disabled()) { | |
| 304 | +        if ($this->disabled()) { | |
| 305 | 305 | return null; | 
| 306 | 306 | } | 
| 307 | 307 | |
| 308 | 308 |          try { | 
| 309 | 309 |              $response = $this->client->request('me'); | 
| 310 | 310 | } | 
| 311 | -        catch(\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) { | |
| 311 | +        catch (\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) { | |
| 312 | 312 | return null; | 
| 313 | 313 | } | 
| 314 | 314 | |
| 315 | -        if(!$this->client->success(true)) { | |
| 315 | +        if (!$this->client->success(true)) { | |
| 316 | 316 | return null; | 
| 317 | 317 | } | 
| 318 | 318 | |
| @@ -346,7 +346,7 @@ discard block | ||
| 346 | 346 |      { | 
| 347 | 347 |          $handler = camel_case(str_replace('.', ' ', $key)); | 
| 348 | 348 | |
| 349 | -        if(!method_exists($this->handlersContainer, $handler)) { | |
| 349 | +        if (!method_exists($this->handlersContainer, $handler)) { | |
| 350 | 350 |              throw new \InvalidArgumentException("Handler `{$handler}` cannot be found"); | 
| 351 | 351 | } | 
| 352 | 352 | |
| @@ -391,10 +391,10 @@ discard block | ||
| 391 | 391 |          try { | 
| 392 | 392 | $output = $callback(); | 
| 393 | 393 | } | 
| 394 | -        catch(\Exception $e) { | |
| 394 | +        catch (\Exception $e) { | |
| 395 | 395 | DB::rollBack(); | 
| 396 | 396 | |
| 397 | -            if(is_null($fallback)) { | |
| 397 | +            if (is_null($fallback)) { | |
| 398 | 398 | throw $e; | 
| 399 | 399 | } | 
| 400 | 400 | |
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 |      { | 
| 29 | 29 | $handler = 'action' . studly_case($action); | 
| 30 | 30 | |
| 31 | -        if(!method_exists($this, $handler)) { | |
| 31 | +        if (!method_exists($this, $handler)) { | |
| 32 | 32 |              throw new \Slides\Connector\Auth\Exceptions\SyncException("User action handler {$handler} cannot be found."); | 
| 33 | 33 | } | 
| 34 | 34 | |
| @@ -45,7 +45,7 @@ discard block | ||
| 45 | 45 | protected function actionCreate(RemoteUser $remote) | 
| 46 | 46 |      { | 
| 47 | 47 | // If a user with the same email was found, we need to skip the process | 
| 48 | -        if(Auth::getProvider()->retrieveByCredentials(['email' => strtolower($remote->getEmail())])) { | |
| 48 | +        if (Auth::getProvider()->retrieveByCredentials(['email' => strtolower($remote->getEmail())])) { | |
| 49 | 49 | return; | 
| 50 | 50 | } | 
| 51 | 51 | |
| @@ -64,18 +64,18 @@ discard block | ||
| 64 | 64 | protected function actionUpdate(RemoteUser $remote) | 
| 65 | 65 |      { | 
| 66 | 66 | // If a user with the same email cannot be found, we should skip the process | 
| 67 | -        if(!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) { | |
| 67 | +        if (!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) { | |
| 68 | 68 | return; | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 | // If a local user was updated later than remote one, we should skip the process | 
| 72 | 72 | // Since we have a latest one | 
| 73 | -        if($this->localNewerThanRemote($local, $remote)) { | |
| 73 | +        if ($this->localNewerThanRemote($local, $remote)) { | |
| 74 | 74 | return; | 
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | 77 | // If "password" mode is not enabled, we cannot update local passwords, so we simply resetting it | 
| 78 | -        if(!$this->hasMode(static::MODE_PASSWORDS)) { | |
| 78 | +        if (!$this->hasMode(static::MODE_PASSWORDS)) { | |
| 79 | 79 | $remote->resetPassword(); | 
| 80 | 80 | } | 
| 81 | 81 | |
| @@ -96,7 +96,7 @@ discard block | ||
| 96 | 96 | */ | 
| 97 | 97 | protected function actionDelete(RemoteUser $remote) | 
| 98 | 98 |      { | 
| 99 | -        if(!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) { | |
| 99 | +        if (!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) { | |
| 100 | 100 | return; | 
| 101 | 101 | } | 
| 102 | 102 | |
| @@ -115,15 +115,15 @@ discard block | ||
| 115 | 115 | */ | 
| 116 | 116 | private function localNewerThanRemote(LocalUser $local, RemoteUser $remote) | 
| 117 | 117 |      { | 
| 118 | -        if(!$local->retrieveRemoteId()) { | |
| 118 | +        if (!$local->retrieveRemoteId()) { | |
| 119 | 119 | return false; | 
| 120 | 120 | } | 
| 121 | 121 | |
| 122 | -        if(!$remoteUpdated = $remote->getUpdated()) { | |
| 122 | +        if (!$remoteUpdated = $remote->getUpdated()) { | |
| 123 | 123 | return false; | 
| 124 | 124 | } | 
| 125 | 125 | |
| 126 | -        if(!$localUpdate = $local->retrieveUpdatedAt()) { | |
| 126 | +        if (!$localUpdate = $local->retrieveUpdatedAt()) { | |
| 127 | 127 | return false; | 
| 128 | 128 | } | 
| 129 | 129 | |
| @@ -31,7 +31,7 @@ discard block | ||
| 31 | 31 |      { | 
| 32 | 32 | $difference = $this->parseDump($path, $sharedKey, $importModes); | 
| 33 | 33 | |
| 34 | -        $foreigners = array_map(function (array $user) { | |
| 34 | +        $foreigners = array_map(function(array $user) { | |
| 35 | 35 | return $this->createRemoteUserFromResponse($user); | 
| 36 | 36 | }, $difference); | 
| 37 | 37 | |
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | */ | 
| 55 | 55 | private function parseDump(string $filename, string $sharedKey, bool $importModes): array | 
| 56 | 56 |      { | 
| 57 | -        if(!file_exists($filename)) { | |
| 57 | +        if (!file_exists($filename)) { | |
| 58 | 58 | throw new \InvalidArgumentException($filename . ' cannot be found'); | 
| 59 | 59 | } | 
| 60 | 60 | |
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | // Then delete from a dump so we can proceed with decryption | 
| 67 | 67 | $this->extractHeaders($payload); | 
| 68 | 68 | |
| 69 | -        if($importModes) { | |
| 69 | +        if ($importModes) { | |
| 70 | 70 | $this->modes = array_get($this->importHeaders, 'modes', []); | 
| 71 | 71 | } | 
| 72 | 72 | |
| @@ -54,7 +54,7 @@ | ||
| 54 | 54 | */ | 
| 55 | 55 | public function getEncryptionKey() | 
| 56 | 56 |      { | 
| 57 | -        if(!$this->encryptionKey) { | |
| 57 | +        if (!$this->encryptionKey) { | |
| 58 | 58 | return null; | 
| 59 | 59 | } | 
| 60 | 60 | |
| @@ -157,7 +157,7 @@ discard block | ||
| 157 | 157 | */ | 
| 158 | 158 | protected function parseResponse(array $response) | 
| 159 | 159 |      { | 
| 160 | -        $foreigners = array_map(function (array $user) { | |
| 160 | +        $foreigners = array_map(function(array $user) { | |
| 161 | 161 | return $this->createRemoteUserFromResponse($user); | 
| 162 | 162 | }, array_get($response, 'difference')); | 
| 163 | 163 | |
| @@ -197,7 +197,7 @@ discard block | ||
| 197 | 197 | $action = $foreigner->getRemoteAction() | 
| 198 | 198 | ); | 
| 199 | 199 | } | 
| 200 | -            catch(\Slides\Connector\Auth\Exceptions\SyncException $e) { | |
| 200 | +            catch (\Slides\Connector\Auth\Exceptions\SyncException $e) { | |
| 201 | 201 | \Illuminate\Support\Facades\Log::error( | 
| 202 | 202 |                      "Cannot $action the user {$foreigner->getEmail()}: " . $e->getMessage() | 
| 203 | 203 | ); | 
| @@ -358,7 +358,7 @@ discard block | ||
| 358 | 358 |      { | 
| 359 | 359 | $output[] = $message; | 
| 360 | 360 | |
| 361 | -        if($this->outputCallback instanceof \Closure) { | |
| 361 | +        if ($this->outputCallback instanceof \Closure) { | |
| 362 | 362 | call_user_func($this->outputCallback, $message); | 
| 363 | 363 | } | 
| 364 | 364 | } | 
| @@ -196,8 +196,7 @@ | ||
| 196 | 196 | $foreigner, | 
| 197 | 197 | $action = $foreigner->getRemoteAction() | 
| 198 | 198 | ); | 
| 199 | - } | |
| 200 | -            catch(\Slides\Connector\Auth\Exceptions\SyncException $e) { | |
| 199 | +            } catch(\Slides\Connector\Auth\Exceptions\SyncException $e) { | |
| 201 | 200 | \Illuminate\Support\Facades\Log::error( | 
| 202 | 201 |                      "Cannot $action the user {$foreigner->getEmail()}: " . $e->getMessage() | 
| 203 | 202 | ); | 
| @@ -2,6 +2,6 @@ | ||
| 2 | 2 | |
| 3 | 3 | use Illuminate\Support\Facades\Route; | 
| 4 | 4 | |
| 5 | -Route::group(['namespace' => 'Slides\Connector\Auth\Http\Controllers'], function () { | |
| 5 | +Route::group(['namespace' => 'Slides\Connector\Auth\Http\Controllers'], function() { | |
| 6 | 6 |      Route::post('connector/webhook/{key}', 'WebhookController'); | 
| 7 | 7 | }); | 
| 8 | 8 | \ No newline at end of file |