@@ -12,31 +12,31 @@ |
||
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 | - }elseif($provider === 'facebook'){ |
|
17 | + }elseif ($provider === 'facebook') { |
|
18 | 18 | $user = Socialite::driver($provider)->fields(['name', 'first_name', 'last_name', 'email'])->user(); |
19 | - }else { |
|
19 | + } else { |
|
20 | 20 | $user = Socialite::driver($provider)->stateless()->user(); |
21 | 21 | } |
22 | 22 | |
23 | 23 | $email = $user->getEmail(); |
24 | 24 | |
25 | 25 | // For twitter, we prefer to use the name. If empty we'll use the twitter account (nickname): |
26 | - $firstname = $user->getName() !== null ? $user->getName() : $user->getNickname(); |
|
27 | - if(!empty($user->user['given_name'])){ |
|
26 | + $firstname = $user->getName() !== null ? $user->getName() : $user->getNickname(); |
|
27 | + if (!empty($user->user['given_name'])) { |
|
28 | 28 | |
29 | 29 | $firstname = $user->user['given_name']; |
30 | - }elseif (!empty($user->user['first_name'])){ |
|
30 | + }elseif (!empty($user->user['first_name'])) { |
|
31 | 31 | |
32 | 32 | $firstname = $user->user['first_name']; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $lastname = $user->getName(); |
36 | - if(!empty($user->user['family_name'])){ |
|
36 | + if (!empty($user->user['family_name'])) { |
|
37 | 37 | |
38 | 38 | $lastname = $user->user['family_name']; |
39 | - }elseif (!empty($user->user['last_name'])){ |
|
39 | + }elseif (!empty($user->user['last_name'])) { |
|
40 | 40 | |
41 | 41 | $lastname = $user->user['last_name']; |
42 | 42 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $fillWikiUserProfile->fill(Auth::user()->uuid, $role, $firstname, $lastname, $email, $postalCode, $farmingType); |
47 | 47 | |
48 | - if(Auth::user()->hasVerifiedEmail()) { |
|
48 | + if (Auth::user()->hasVerifiedEmail()) { |
|
49 | 49 | $user = Auth::user(); |
50 | 50 | if ($request->session()->has('wiki_callback')) { |
51 | 51 | $user->wiki_token = $request->session()->get('wiki_token'); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | return redirect($callback); |
55 | 55 | } |
56 | 56 | |
57 | - if($request->session()->has('sso')){ |
|
57 | + if ($request->session()->has('sso')) { |
|
58 | 58 | $sso = $request->session()->get('sso'); |
59 | 59 | $sig = $request->session()->get('sig'); |
60 | 60 | return redirect('discourse/sso?sso='.$sso.'&sig='.$sig); |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | |
25 | 25 | public function showLoginForm(Request $request) |
26 | 26 | { |
27 | - if($request->session()->has('should_attach_to_organization')) { |
|
27 | + if ($request->session()->has('should_attach_to_organization')) { |
|
28 | 28 | session()->reflash(); |
29 | 29 | } |
30 | 30 | |
31 | - if($request->has('wiki_callback')){ |
|
31 | + if ($request->has('wiki_callback')) { |
|
32 | 32 | session()->flash('wiki_callback', $request->input('wiki_callback')); |
33 | 33 | session()->flash('wiki_token', $request->input('wiki_token')); |
34 | 34 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function logout(Request $request) |
39 | 39 | { |
40 | - if($request->session()->has('should_attach_to_organization')) { |
|
40 | + if ($request->session()->has('should_attach_to_organization')) { |
|
41 | 41 | $shouldAttach = $request->session()->get('should_attach_to_organization'); |
42 | 42 | $shouldAttachToken = $request->session()->get('should_attach_to_organization_token'); |
43 | 43 | $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect'); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $request->session()->regenerateToken(); |
51 | 51 | |
52 | - if(isset($shouldAttach)){ |
|
52 | + if (isset($shouldAttach)) { |
|
53 | 53 | $request->session()->flash('should_attach_to_organization', $shouldAttach); |
54 | 54 | $request->session()->flash('should_attach_to_organization_token', $shouldAttachToken); |
55 | 55 | $request->session()->flash('should_attach_to_organization_redirect', $linkToRedirect); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | protected function loggedOut(Request $request) |
68 | 68 | { |
69 | 69 | $request->session()->reflash(); |
70 | - if($request->session()->has('should_attach_to_organization')){ |
|
70 | + if ($request->session()->has('should_attach_to_organization')) { |
|
71 | 71 | $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect'); |
72 | 72 | return $request->wantsJson() |
73 | 73 | ? new Response('', 204) |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | |
78 | 78 | protected function authenticated(Request $request, $user) |
79 | 79 | { |
80 | - if($user->context_id === null){ |
|
80 | + if ($user->context_id === null) { |
|
81 | 81 | return redirect()->route('wizard.profile'); |
82 | 82 | } |
83 | 83 | |
84 | - if($request->session()->has('sso')){ |
|
85 | - if(!$user->hasVerifiedEmail()){ |
|
84 | + if ($request->session()->has('sso')) { |
|
85 | + if (!$user->hasVerifiedEmail()) { |
|
86 | 86 | return redirect()->route('verification.notice'); |
87 | 87 | } |
88 | 88 | $sso = $request->session()->get('sso'); |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | return redirect('discourse/sso?sso='.$sso.'&sig='.$sig); |
91 | 91 | } |
92 | 92 | |
93 | - if($request->session()->has('wiki_callback')){ |
|
93 | + if ($request->session()->has('wiki_callback')) { |
|
94 | 94 | $user->wiki_token = $request->session()->get('wiki_token'); |
95 | 95 | $user->save(); |
96 | 96 | $callback = urldecode($request->session()->get('wiki_callback')); |
97 | - if(!$user->hasVerifiedEmail()){ |
|
97 | + if (!$user->hasVerifiedEmail()) { |
|
98 | 98 | return redirect()->route('verification.notice'); |
99 | 99 | } |
100 | 100 | return redirect($callback); |
101 | 101 | } |
102 | 102 | |
103 | - if($request->session()->has('should_attach_to_organization') && $request->session()->get('should_attach_to_organization') !== null){ |
|
103 | + if ($request->session()->has('should_attach_to_organization') && $request->session()->get('should_attach_to_organization') !== null) { |
|
104 | 104 | $token = $request->session()->get('should_attach_to_organization_token'); |
105 | 105 | $link = route('organization.invite.show').'?&token='.$token; |
106 | 106 | return $request->wantsJson() |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | public function redirectToProvider(string $provider) |
114 | 114 | { |
115 | - if($provider === 'twitter'){ |
|
115 | + if ($provider === 'twitter') { |
|
116 | 116 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK_LOGIN')]); |
117 | 117 | return Socialite::driver($provider)->redirect(); |
118 | 118 | } |
@@ -31,19 +31,19 @@ discard block |
||
31 | 31 | { |
32 | 32 | $email = $firstname = $lastname = ''; |
33 | 33 | |
34 | - if($request->session()->has('user_to_register')){ |
|
34 | + if ($request->session()->has('user_to_register')) { |
|
35 | 35 | $user = $request->session()->get('user_to_register'); |
36 | 36 | $email = $user['email']; |
37 | 37 | $firstname = $user['firstname']; |
38 | 38 | $lastname = $user['lastname']; |
39 | 39 | } |
40 | 40 | |
41 | - if($request->has('wiki_callback')){ |
|
41 | + if ($request->has('wiki_callback')) { |
|
42 | 42 | session()->flash('wiki_callback', $request->input('wiki_callback')); |
43 | 43 | session()->flash('wiki_token', $request->input('wiki_token')); |
44 | 44 | } |
45 | 45 | |
46 | - if(session()->has('should_attach_to_organization')) { |
|
46 | + if (session()->has('should_attach_to_organization')) { |
|
47 | 47 | session()->reflash(); |
48 | 48 | } |
49 | 49 | return view('public.auth.register', [ |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | protected function validator(array $data) |
57 | 57 | { |
58 | - if(session()->has('should_attach_to_organization')) { |
|
58 | + if (session()->has('should_attach_to_organization')) { |
|
59 | 59 | session()->reflash(); |
60 | 60 | } |
61 | 61 | return Validator::make($data, [ |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | protected function registered(Request $request, $user) |
82 | 82 | { |
83 | 83 | $this->guard()->login($user, true); |
84 | - if($request->session()->has('should_attach_to_organization')){ |
|
84 | + if ($request->session()->has('should_attach_to_organization')) { |
|
85 | 85 | app(AttachUserToAnOrganization::class)->attach($user->uuid, $request->session()->get('should_attach_to_organization')); |
86 | 86 | } |
87 | 87 | $user = Auth::user(); |
88 | 88 | |
89 | - if($user->context_id === null) { |
|
90 | - if($request->session()->has('wiki_token')) { |
|
89 | + if ($user->context_id === null) { |
|
90 | + if ($request->session()->has('wiki_token')) { |
|
91 | 91 | $user->wiki_token = $request->session()->get('wiki_token'); |
92 | 92 | $user->save(); |
93 | 93 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * should be deleted dead code ? |
100 | 100 | */ |
101 | - if($request->session()->has('wiki_callback')){ |
|
101 | + if ($request->session()->has('wiki_callback')) { |
|
102 | 102 | $user->wiki_token = $request->session()->get('wiki_token'); |
103 | 103 | $user->save(); |
104 | 104 | $callback = urldecode($request->session()->get('wiki_callback')); |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | |
111 | 111 | public function redirectToProvider(string $provider) |
112 | 112 | { |
113 | - if(request()->session()->has('wiki_token')) { |
|
113 | + if (request()->session()->has('wiki_token')) { |
|
114 | 114 | session()->reflash(); |
115 | 115 | } |
116 | 116 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK')]); |
117 | - if($provider === 'twitter'){ |
|
117 | + if ($provider === 'twitter') { |
|
118 | 118 | return Socialite::driver($provider)->redirect(); |
119 | 119 | } |
120 | 120 | return Socialite::driver($provider)->redirectUrl(config('services.'.$provider.'.redirect'))->redirect(); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $user = User::where('uuid', $userId)->first(); |
128 | 128 | $this->guard()->login($user); |
129 | 129 | |
130 | - if($user->context_id !== null){ |
|
130 | + if ($user->context_id !== null) { |
|
131 | 131 | $user->wiki_token = $request->session()->get('wiki_token'); |
132 | 132 | $user->save(); |
133 | 133 | $callback = urldecode($request->session()->get('wiki_callback')); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | return redirect()->route('wizard.profile'); |
138 | - }catch (ValidationException $e) { |
|
138 | + } catch (ValidationException $e) { |
|
139 | 139 | $attributes = $e->validator->attributes(); |
140 | 140 | $attributes['provider'] = $provider; |
141 | 141 | return redirect()->route('register-social-network') |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | private function handleDepartments($departments) |
52 | 52 | { |
53 | - foreach($departments as $department){ |
|
53 | + foreach ($departments as $department) { |
|
54 | 54 | $key = key($department); |
55 | 55 | $department = last($department)['printouts']; |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $iconUrlApi = str_replace(':file:', last($department['A une icone'])['fulltext'], $this->queryPictures); |
61 | 61 | |
62 | 62 | $characteristicModel = CharacteristicsModel::query()->where('code', $number)->first(); |
63 | - if(!isset($characteristicModel)){ |
|
63 | + if (!isset($characteristicModel)) { |
|
64 | 64 | $characteristicModel = new CharacteristicsModel(); |
65 | 65 | } |
66 | 66 | |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | $response = $this->httpClient->get(config('wiki.api_uri').$iconUrlApi); |
81 | 81 | $content = json_decode($response->getBody()->getContents(), true); |
82 | 82 | $picturesInfo = $content['query']['pages']; |
83 | - foreach($picturesInfo as $picture) { |
|
83 | + foreach ($picturesInfo as $picture) { |
|
84 | 84 | if (isset($picture['imageinfo']) && isset(last($picture['imageinfo'])['url'])) { |
85 | 85 | $characteristicModel->page_id = $picture['pageid']; |
86 | 86 | try { |
87 | 87 | $response = $this->httpClient->get(last($picture['imageinfo'])['url']); |
88 | 88 | $content = $response->getBody()->getContents(); |
89 | - $path = 'public/characteristics/' . $uuid . '.png'; |
|
90 | - Storage::put('public/characteristics/' . $uuid . '.png', $content); |
|
91 | - }catch (ClientException $e){ |
|
89 | + $path = 'public/characteristics/'.$uuid.'.png'; |
|
90 | + Storage::put('public/characteristics/'.$uuid.'.png', $content); |
|
91 | + } catch (ClientException $e) { |
|
92 | 92 | $this->info('No icon for department : '.$number); |
93 | 93 | $path = ''; |
94 | 94 | } |
95 | - }else{ |
|
95 | + } else { |
|
96 | 96 | $this->info('No icon for department : '.$number); |
97 | 97 | $path = ''; |
98 | 98 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $httpClient = new Client(); |
26 | 26 | |
27 | - PageModel::query()->where('dry', true)->chunkById(50, function ($items, $count) use($httpClient){ |
|
27 | + PageModel::query()->where('dry', true)->chunkById(50, function($items, $count) use($httpClient){ |
|
28 | 28 | $this->info(($count*50).' Pages'); |
29 | 29 | $pages = $items->pluck('page_id')->toArray(); |
30 | 30 | $pagesApiUri = config('wiki.api_uri').$this->queryPages.implode('|', $pages); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | $content = json_decode($response->getBody()->getContents(), true); |
33 | 33 | $wikiPages = $content['query']['pages']; |
34 | 34 | |
35 | - foreach($wikiPages as $page){ |
|
35 | + foreach ($wikiPages as $page) { |
|
36 | 36 | $pageModel = PageModel::query()->where('page_id', $page['pageid'])->first(); |
37 | 37 | |
38 | - if(!isset($pageModel)){ |
|
38 | + if (!isset($pageModel)) { |
|
39 | 39 | continue; |
40 | 40 | } |
41 | 41 |