@@ -12,15 +12,15 @@ |
||
| 12 | 12 | { |
| 13 | 13 | public function user(string $provider): SocialiteUser |
| 14 | 14 | { |
| 15 | - if($provider === 'twitter'){ |
|
| 15 | + if ($provider === 'twitter') { |
|
| 16 | 16 | $user = Socialite::driver($provider)->user(); |
| 17 | - }else { |
|
| 17 | + } else { |
|
| 18 | 18 | $user = Socialite::driver($provider)->stateless()->user(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $email = $user->getEmail(); |
| 22 | 22 | $firstname = $user->getNickname() !== null ? $user->getNickname() : $user->getName(); |
| 23 | - if(isset($user->user['given_name'])){ |
|
| 23 | + if (isset($user->user['given_name'])) { |
|
| 24 | 24 | $firstname = $user->user['given_name']; |
| 25 | 25 | } |
| 26 | 26 | $lastname = isset($user->user['family_name']) ? $user->user['family_name'] : $user->getName(); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | { |
| 15 | 15 | if($provider === 'twitter'){ |
| 16 | 16 | $user = Socialite::driver($provider)->user(); |
| 17 | - }else { |
|
| 17 | + } else { |
|
| 18 | 18 | $user = Socialite::driver($provider)->stateless()->user(); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -36,31 +36,31 @@ |
||
| 36 | 36 | { |
| 37 | 37 | $this->registerHelpers(); |
| 38 | 38 | |
| 39 | - if(config('app.env') === 'testing'){ |
|
| 39 | + if (config('app.env') === 'testing') { |
|
| 40 | 40 | $this->tuBinding(); |
| 41 | 41 | } |
| 42 | - if(config('app.env') === 'testing-ti'){ |
|
| 42 | + if (config('app.env') === 'testing-ti') { |
|
| 43 | 43 | $this->tiBinding(); |
| 44 | 44 | } |
| 45 | - if(config('app.env') === 'local' || config('app.env') === 'production'){ |
|
| 45 | + if (config('app.env') === 'local' || config('app.env') === 'production') { |
|
| 46 | 46 | $this->prodBinding(); |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function boot() |
| 51 | 51 | { |
| 52 | - if(config('app.env') !== 'testing' && config('app.env') !== 'testing-ti') { |
|
| 52 | + if (config('app.env') !== 'testing' && config('app.env') !== 'testing-ti') { |
|
| 53 | 53 | Schema::defaultStringLength(191); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if(config('app.env') === 'local' || config('app.env') === 'production'){ |
|
| 56 | + if (config('app.env') === 'local' || config('app.env') === 'production') { |
|
| 57 | 57 | URL::forceScheme('https'); |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | private function registerHelpers(): void |
| 62 | 62 | { |
| 63 | - foreach (glob(app_path() . '/Src/Utils/Helpers/*.php') as $filename) { |
|
| 63 | + foreach (glob(app_path().'/Src/Utils/Helpers/*.php') as $filename) { |
|
| 64 | 64 | require_once($filename); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -9,14 +9,14 @@ |
||
| 9 | 9 | public function handle($request, Closure $next, $guard = null) |
| 10 | 10 | { |
| 11 | 11 | $params = $request->all(); |
| 12 | - if(isset($params['\code'])) { |
|
| 12 | + if (isset($params['\code'])) { |
|
| 13 | 13 | $request->merge([ |
| 14 | 14 | '\code' => null, |
| 15 | 15 | 'code' => $params['\code'] |
| 16 | 16 | ]); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if(isset($params['\oauth_token'])) { |
|
| 19 | + if (isset($params['\oauth_token'])) { |
|
| 20 | 20 | $request->merge([ |
| 21 | 21 | '\oauth_token' => null, |
| 22 | 22 | 'oauth_token' => $params['\oauth_token'] |
@@ -18,20 +18,20 @@ discard block |
||
| 18 | 18 | $this->users[] = $u; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getByEmail(string $email):?User |
|
| 21 | + public function getByEmail(string $email): ?User |
|
| 22 | 22 | { |
| 23 | - foreach ($this->users as $user){ |
|
| 24 | - if($user->email() === $email){ |
|
| 23 | + foreach ($this->users as $user) { |
|
| 24 | + if ($user->email() === $email) { |
|
| 25 | 25 | return $user; |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | return null; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function getById(string $id):?User |
|
| 31 | + public function getById(string $id): ?User |
|
| 32 | 32 | { |
| 33 | - foreach ($this->users as $user){ |
|
| 34 | - if($user->id() === $id){ |
|
| 33 | + foreach ($this->users as $user) { |
|
| 34 | + if ($user->id() === $id) { |
|
| 35 | 35 | return $user; |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | public function search(string $organizationId, int $page, int $perPage = 10): array |
| 42 | 42 | { |
| 43 | 43 | $users = []; |
| 44 | - foreach($this->users as $user){ |
|
| 45 | - if($user->organizationId() === $organizationId){ |
|
| 44 | + foreach ($this->users as $user) { |
|
| 45 | + if ($user->organizationId() === $organizationId) { |
|
| 46 | 46 | $users[] = $user->toDto(); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | public function update(User $u) |
| 58 | 58 | { |
| 59 | - foreach ($this->users as $key => $user){ |
|
| 60 | - if($user->id() === $u->id()){ |
|
| 59 | + foreach ($this->users as $key => $user) { |
|
| 60 | + if ($user->id() === $u->id()) { |
|
| 61 | 61 | $this->users[$key] = $u; |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function updateProviders(User $u) |
| 67 | 67 | { |
| 68 | - foreach ($this->users as $key => $user){ |
|
| 69 | - if($user->id() === $u->id()){ |
|
| 68 | + foreach ($this->users as $key => $user) { |
|
| 69 | + if ($user->id() === $u->id()) { |
|
| 70 | 70 | $this->users[$key] = $u; |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function delete(string $userId) |
| 76 | 76 | { |
| 77 | - foreach ($this->users as $key => $user){ |
|
| 78 | - if($user->id() === $userId){ |
|
| 77 | + foreach ($this->users as $key => $user) { |
|
| 78 | + if ($user->id() === $userId) { |
|
| 79 | 79 | unset($this->users[$key]); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | public function getAdminOfOrganization(string $organizationId): array |
| 85 | 85 | { |
| 86 | 86 | $users = []; |
| 87 | - foreach ($this->users as $key => $user){ |
|
| 88 | - if($user->organizationId() === $organizationId && $user->isAdmin()){ |
|
| 87 | + foreach ($this->users as $key => $user) { |
|
| 88 | + if ($user->organizationId() === $organizationId && $user->isAdmin()) { |
|
| 89 | 89 | $users[] = $user; |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | public function getByProvider(string $provider, string $providerId): ?User |
| 96 | 96 | { |
| 97 | - foreach ($this->users as $user){ |
|
| 98 | - if($user->provider($provider, $providerId) === true){ |
|
| 97 | + foreach ($this->users as $user) { |
|
| 98 | + if ($user->provider($provider, $providerId) === true) { |
|
| 99 | 99 | return $user; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | return $this->providerId; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function email():? string |
|
| 30 | + public function email(): ? string |
|
| 31 | 31 | { |
| 32 | 32 | return $this->email; |
| 33 | 33 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function register(string $provider, SocialiteUser $socialiteUser) |
| 30 | 30 | { |
| 31 | 31 | $user = $this->userRepository->getByProvider($provider, $socialiteUser->providerId()); |
| 32 | - if(isset($user)){ |
|
| 32 | + if (isset($user)) { |
|
| 33 | 33 | return [ |
| 34 | 34 | 'user_id' => $user->id(), |
| 35 | 35 | 'provider_id' => $socialiteUser->providerId(), |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | ]; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if($socialiteUser->email() !== null) { |
|
| 40 | + if ($socialiteUser->email() !== null) { |
|
| 41 | 41 | $user = $this->userRepository->getByEmail($socialiteUser->email()); |
| 42 | 42 | } |
| 43 | - if(isset($user)){ |
|
| 43 | + if (isset($user)) { |
|
| 44 | 44 | $user->addProvider($provider, $socialiteUser->providerId()); |
| 45 | 45 | return [ |
| 46 | 46 | 'user_id' => $user->id(), |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | $socialiteUser = $this->socialiteGateway->user($provider); |
| 41 | 41 | |
| 42 | 42 | $user = $this->userRepository->getByProvider($provider, $socialiteUser->providerId()); |
| 43 | - if($user === null){ |
|
| 43 | + if ($user === null) { |
|
| 44 | 44 | app(RegisterUserFromSocialNetworkService::class)->register($provider, $socialiteUser); |
| 45 | 45 | $user = $this->userRepository->getByProvider($provider, $socialiteUser->providerId()); |
| 46 | 46 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public function showLoginForm(Request $request) |
| 26 | 26 | { |
| 27 | 27 | session()->reflash(); |
| 28 | - if($request->has('wiki_callback')){ |
|
| 28 | + if ($request->has('wiki_callback')) { |
|
| 29 | 29 | session()->flash('wiki_callback', $request->input('wiki_callback')); |
| 30 | 30 | session()->flash('wiki_token', $request->input('wiki_token')); |
| 31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function logout(Request $request) |
| 36 | 36 | { |
| 37 | - if($request->session()->has('should_attach_to_organization')) { |
|
| 37 | + if ($request->session()->has('should_attach_to_organization')) { |
|
| 38 | 38 | $shouldAttach = $request->session()->get('should_attach_to_organization'); |
| 39 | 39 | $shouldAttachToken = $request->session()->get('should_attach_to_organization_token'); |
| 40 | 40 | $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect'); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $request->session()->regenerateToken(); |
| 48 | 48 | |
| 49 | - if(isset($shouldAttach)){ |
|
| 49 | + if (isset($shouldAttach)) { |
|
| 50 | 50 | $request->session()->flash('should_attach_to_organization', $shouldAttach); |
| 51 | 51 | $request->session()->flash('should_attach_to_organization_token', $shouldAttachToken); |
| 52 | 52 | $request->session()->flash('should_attach_to_organization_redirect', $linkToRedirect); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | protected function loggedOut(Request $request) |
| 65 | 65 | { |
| 66 | 66 | $request->session()->reflash(); |
| 67 | - if($request->session()->has('should_attach_to_organization')){ |
|
| 67 | + if ($request->session()->has('should_attach_to_organization')) { |
|
| 68 | 68 | $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect'); |
| 69 | 69 | return $request->wantsJson() |
| 70 | 70 | ? new Response('', 204) |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | protected function authenticated(Request $request, $user) |
| 76 | 76 | { |
| 77 | - if($request->session()->has('wiki_callback')){ |
|
| 77 | + if ($request->session()->has('wiki_callback')) { |
|
| 78 | 78 | $user = Auth::user(); |
| 79 | 79 | $user->wiki_token = $request->session()->get('wiki_token'); |
| 80 | 80 | $user->save(); |
| 81 | 81 | $callback = urldecode($request->session()->get('wiki_callback')); |
| 82 | 82 | return redirect($callback); |
| 83 | 83 | } |
| 84 | - if($request->session()->has('should_attach_to_organization') && $request->session()->get('should_attach_to_organization') !== null){ |
|
| 84 | + if ($request->session()->has('should_attach_to_organization') && $request->session()->get('should_attach_to_organization') !== null) { |
|
| 85 | 85 | $token = $request->session()->get('should_attach_to_organization_token'); |
| 86 | 86 | $link = route('organization.invite.show').'?&token='.$token; |
| 87 | 87 | return $request->wantsJson() |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function redirectToProvider(string $provider) |
| 94 | 94 | { |
| 95 | - if($provider === 'twitter'){ |
|
| 95 | + if ($provider === 'twitter') { |
|
| 96 | 96 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK_LOGIN')]); |
| 97 | 97 | return Socialite::driver($provider)->redirect(); |
| 98 | 98 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK_LOGIN')]); |
| 107 | 107 | $logUserFromSocialNetwork->log($provider); |
| 108 | - if(session()->has('wiki_callback')){ |
|
| 108 | + if (session()->has('wiki_callback')) { |
|
| 109 | 109 | return $this->authenticated(request(), null); |
| 110 | 110 | } |
| 111 | 111 | return redirect()->route('home'); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $email = $firstname = $lastname = ''; |
| 34 | 34 | |
| 35 | - if($request->session()->has('user_to_register')){ |
|
| 35 | + if ($request->session()->has('user_to_register')) { |
|
| 36 | 36 | $user = $request->session()->get('user_to_register'); |
| 37 | 37 | $email = $user['email']; |
| 38 | 38 | $firstname = $user['firstname']; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | protected function validator(array $data) |
| 50 | 50 | { |
| 51 | - if(session()->has('should_attach_to_organization')) { |
|
| 51 | + if (session()->has('should_attach_to_organization')) { |
|
| 52 | 52 | session()->reflash(); |
| 53 | 53 | } |
| 54 | 54 | return Validator::make($data, [ |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | protected function registered(Request $request, $user) |
| 71 | 71 | { |
| 72 | - if($request->session()->has('should_attach_to_organization')){ |
|
| 72 | + if ($request->session()->has('should_attach_to_organization')) { |
|
| 73 | 73 | app(AttachUserToAnOrganization::class)->attach($user->uuid, $request->session()->get('should_attach_to_organization')); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if($request->session()->has('wiki_callback')){ |
|
| 76 | + if ($request->session()->has('wiki_callback')) { |
|
| 77 | 77 | $user = Auth::user(); |
| 78 | 78 | $user->wiki_token = $request->session()->get('wiki_token'); |
| 79 | 79 | $user->save(); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | public function redirectToProvider(string $provider) |
| 86 | 86 | { |
| 87 | 87 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK')]); |
| 88 | - if($provider === 'twitter'){ |
|
| 88 | + if ($provider === 'twitter') { |
|
| 89 | 89 | return Socialite::driver($provider)->redirect(); |
| 90 | 90 | } |
| 91 | 91 | return Socialite::driver($provider)->redirectUrl(config('services.'.$provider.'.redirect'))->redirect(); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $user = User::where('uuid', $userId)->first(); |
| 99 | 99 | $this->guard()->login($user); |
| 100 | 100 | |
| 101 | - if($request->session()->has('wiki_callback')){ |
|
| 101 | + if ($request->session()->has('wiki_callback')) { |
|
| 102 | 102 | $user = Auth::user(); |
| 103 | 103 | $user->wiki_token = $request->session()->get('wiki_token'); |
| 104 | 104 | $user->save(); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | return $request->wantsJson() |
| 110 | 110 | ? new Response('', 201) |
| 111 | 111 | : redirect($this->redirectPath()); |
| 112 | - }catch (ValidationException $e) { |
|
| 112 | + } catch (ValidationException $e) { |
|
| 113 | 113 | $attributes = $e->validator->attributes(); |
| 114 | 114 | $attributes['provider'] = $provider; |
| 115 | 115 | return redirect()->route('register-social-network') |