@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | ->where('lastname', '<>', '') |
| 39 | 39 | ->whereNotNull('email_verified_at') |
| 40 | 40 | ->whereNull('sync_at_discourse') |
| 41 | - ->chunkById(50, function ($items) use ($clients) { |
|
| 42 | - foreach($items as $user) { |
|
| 41 | + ->chunkById(50, function($items) use ($clients) { |
|
| 42 | + foreach ($items as $user) { |
|
| 43 | 43 | $this->processOneUser($clients, $user); |
| 44 | 44 | } |
| 45 | 45 | }); |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | $this->updateUserDetailsOnDiscourse($user); |
| 61 | 61 | $user->sync_at_discourse = (new \DateTime())->format('Y-m-d H:i:s'); |
| 62 | 62 | $user->save(); |
| 63 | - } catch (\Throwable $e){ |
|
| 63 | + } catch (\Throwable $e) { |
|
| 64 | 64 | if ($e->getCode() === 429) { |
| 65 | 65 | // Too many requests - just sleeping |
| 66 | 66 | $this->error('Too many requests - restarting in a minute....'); |
| 67 | 67 | sleep(60); |
| 68 | 68 | } else { |
| 69 | - $message = 'Discourse sync failed for user : ' . $user->uuid . ' [' . $e->getCode() . '] ' . $e->getMessage(); |
|
| 69 | + $message = 'Discourse sync failed for user : '.$user->uuid.' ['.$e->getCode().'] '.$e->getMessage(); |
|
| 70 | 70 | $this->error($message); |
| 71 | 71 | \Sentry\captureException($e); |
| 72 | 72 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $username = $this->formatUsername($user, $increment); |
| 83 | 83 | |
| 84 | 84 | $result = $this->forumApiClient->createUser($username, $user); |
| 85 | - if($result['success'] === false){ |
|
| 85 | + if ($result['success'] === false) { |
|
| 86 | 86 | if (!empty($result['errors']['email'])) { |
| 87 | 87 | return $this->updateUsernameFromDiscourse($user); |
| 88 | 88 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | throw $th; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if(empty($result['user'])){ |
|
| 124 | + if (empty($result['user'])) { |
|
| 125 | 125 | throw new \Exception('Duplicate email not corresponding to existing user'); |
| 126 | 126 | } |
| 127 | 127 | $user->discourse_id = $result['user']['id']; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $result = $this->forumApiClient->getUserByEmail($user->email); |
| 147 | 147 | |
| 148 | - if(empty($result[0]['email']) || strtolower($result[0]['email']) != strtolower($user->email)){ |
|
| 148 | + if (empty($result[0]['email']) || strtolower($result[0]['email']) != strtolower($user->email)) { |
|
| 149 | 149 | throw new \Exception('Duplicate email not corresponding to existing user'); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | try { |
| 164 | 164 | $this->forumApiClient->updateEmail($user->discourse_username, $user->email); |
| 165 | - }catch (\Throwable $e){ |
|
| 165 | + } catch (\Throwable $e) { |
|
| 166 | 166 | $this->error('User email not updated on discourse with id : '.$user->discourse_username); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $result = $this->forumApiClient->updateUser($user, $newBio); |
| 182 | 182 | |
| 183 | - if($result['success'] === false){ |
|
| 183 | + if ($result['success'] === false) { |
|
| 184 | 184 | $this->error('Not Updating bio : '.$result['message']); |
| 185 | 185 | throw new \Exception($result['message']); |
| 186 | 186 | } |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function formatUsername(User $user, int $increment): string |
| 200 | 200 | { |
| 201 | - $username = trim(substr((string)Str::of($user->fullname)->slug('.'), 0, 20), '.'); |
|
| 201 | + $username = trim(substr((string) Str::of($user->fullname)->slug('.'), 0, 20), '.'); |
|
| 202 | 202 | if (empty($username)) { |
| 203 | 203 | throw new \Exception("Empty username", 55); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - return !empty($increment) ? $username . $increment : $username; |
|
| 206 | + return !empty($increment) ? $username.$increment : $username; |
|
| 207 | 207 | } |
| 208 | 208 | } |
@@ -27,16 +27,16 @@ |
||
| 27 | 27 | PageModel::query() |
| 28 | 28 | ->where('dry', true) |
| 29 | 29 | ->where('wiki', $wikiCode) |
| 30 | - ->chunkById(50, function ($items, $count) use($client){ |
|
| 30 | + ->chunkById(50, function($items, $count) use($client){ |
|
| 31 | 31 | $this->info(($count*50).' Pages'); |
| 32 | 32 | $pages = $items->pluck('page_id')->toArray(); |
| 33 | 33 | $content = $client->searchPagesById($pages); |
| 34 | 34 | $wikiPages = $content['query']['pages']; |
| 35 | 35 | |
| 36 | - foreach($wikiPages as $page){ |
|
| 36 | + foreach ($wikiPages as $page) { |
|
| 37 | 37 | $pageModel = PageModel::query()->where('page_id', $page['pageid'])->first(); |
| 38 | 38 | |
| 39 | - if(!isset($pageModel)){ |
|
| 39 | + if (!isset($pageModel)) { |
|
| 40 | 40 | continue; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | private function handleDepartments($departments) |
| 57 | 57 | { |
| 58 | - foreach($departments as $department){ |
|
| 58 | + foreach ($departments as $department) { |
|
| 59 | 59 | $key = key($department); |
| 60 | 60 | $department = last($department)['printouts']; |
| 61 | 61 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $iconUrlApi = str_replace(':file:', last($department['A une icone'])['fulltext'], $this->queryPictures); |
| 66 | 66 | |
| 67 | 67 | $characteristicModel = CharacteristicsModel::query()->where('code', $number)->first(); |
| 68 | - if(!isset($characteristicModel)){ |
|
| 68 | + if (!isset($characteristicModel)) { |
|
| 69 | 69 | $characteristicModel = new CharacteristicsModel(); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $response = $this->httpClient->get(config('wiki.api_uri').$iconUrlApi); |
| 86 | 86 | $content = json_decode($response->getBody()->getContents(), true); |
| 87 | 87 | $picturesInfo = $content['query']['pages']; |
| 88 | - foreach($picturesInfo as $picture) { |
|
| 88 | + foreach ($picturesInfo as $picture) { |
|
| 89 | 89 | if (isset($picture['imageinfo']) && isset(last($picture['imageinfo'])['url'])) { |
| 90 | 90 | $characteristicModel->page_id = $picture['pageid']; |
| 91 | 91 | try { |
@@ -96,13 +96,13 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $response = $this->httpClient->get($imageURL); |
| 98 | 98 | $content = $response->getBody()->getContents(); |
| 99 | - $path = 'public/characteristics/' . $uuid . '.png'; |
|
| 100 | - Storage::put('public/characteristics/' . $uuid . '.png', $content); |
|
| 101 | - }catch (ClientException $e){ |
|
| 99 | + $path = 'public/characteristics/'.$uuid.'.png'; |
|
| 100 | + Storage::put('public/characteristics/'.$uuid.'.png', $content); |
|
| 101 | + } catch (ClientException $e) { |
|
| 102 | 102 | $this->info('No icon for department : '.$number); |
| 103 | 103 | $path = ''; |
| 104 | 104 | } |
| 105 | - }else{ |
|
| 105 | + } else { |
|
| 106 | 106 | $this->info('No icon for department : '.$number); |
| 107 | 107 | $path = ''; |
| 108 | 108 | } |
@@ -28,12 +28,12 @@ |
||
| 28 | 28 | try { |
| 29 | 29 | $this->sendingBlueService->addEmailToList($verified->user->email, $verified->user->lastname, $verified->user->firstname); |
| 30 | 30 | } catch (\Throwable $e) { |
| 31 | - Log::critical('Error when adding email to sending blue : ' . $verified->user->email); |
|
| 31 | + Log::critical('Error when adding email to sending blue : '.$verified->user->email); |
|
| 32 | 32 | } |
| 33 | 33 | try { |
| 34 | 34 | $this->mailerLiteService->addEmailToList($verified->user->email); |
| 35 | 35 | } catch (\Exception $e) { |
| 36 | - Log::critical('Error when adding email to mailerlite : ' . $verified->user->email); |
|
| 36 | + Log::critical('Error when adding email to mailerlite : '.$verified->user->email); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -13,13 +13,13 @@ |
||
| 13 | 13 | { |
| 14 | 14 | try { |
| 15 | 15 | $user = $verified->user; |
| 16 | - if(empty($user->firstname) || empty($user->lastname)){ |
|
| 16 | + if (empty($user->firstname) || empty($user->lastname)) { |
|
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | $user->sync_at_discourse = null; |
| 21 | 21 | $user->save(); |
| 22 | - }catch (\Throwable $e){ |
|
| 22 | + } catch (\Throwable $e) { |
|
| 23 | 23 | Log::emergency('Error when sync asking for user : '.$user->id); |
| 24 | 24 | \Sentry\captureException($e); |
| 25 | 25 | } |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | 'status' => self::STATUS |
| 31 | 31 | ]); |
| 32 | 32 | |
| 33 | - Log::info('Email added to mailerlite : ' . $email); |
|
| 33 | + Log::info('Email added to mailerlite : '.$email); |
|
| 34 | 34 | } catch (\Exception $e) { |
| 35 | - Log::critical('Error when adding email to mailerlite: ' . $email . ' - ' . $e->getMessage()); |
|
| 35 | + Log::critical('Error when adding email to mailerlite: '.$email.' - '.$e->getMessage()); |
|
| 36 | 36 | captureException($e); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | protected function redirectTo($request) |
| 16 | 16 | { |
| 17 | - if($request->has('sso')){ |
|
| 17 | + if ($request->has('sso')) { |
|
| 18 | 18 | list(,$wikiCode,) = explode('/', $request->getRequestUri()); |
| 19 | 19 | session()->put('sso', $request->get('sso')); |
| 20 | 20 | session()->put('sig', $request->get('sig')); |
| 21 | 21 | session()->put('wikiCode', strtolower($wikiCode)); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - if (! $request->expectsJson()) { |
|
| 24 | + if (!$request->expectsJson()) { |
|
| 25 | 25 | return route('login'); |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $email = $firstname = $lastname = ''; |
| 32 | 32 | |
| 33 | - if($request->session()->has('user_to_register')){ |
|
| 33 | + if ($request->session()->has('user_to_register')) { |
|
| 34 | 34 | $user = $request->session()->get('user_to_register'); |
| 35 | 35 | $email = $user['email']; |
| 36 | 36 | $firstname = $user['firstname']; |
| 37 | 37 | $lastname = $user['lastname']; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if($request->has('wiki_callback')){ |
|
| 40 | + if ($request->has('wiki_callback')) { |
|
| 41 | 41 | session()->flash('wiki_callback', $request->input('wiki_callback')); |
| 42 | 42 | session()->flash('wiki_token', $request->input('wiki_token')); |
| 43 | 43 | } |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $user = Auth::user(); |
| 87 | 87 | |
| 88 | - if($user->context_id === null) { |
|
| 89 | - if($request->session()->has('wiki_token')) { |
|
| 88 | + if ($user->context_id === null) { |
|
| 89 | + if ($request->session()->has('wiki_token')) { |
|
| 90 | 90 | $user->wiki_token = $request->session()->get('wiki_token'); |
| 91 | 91 | $user->save(); |
| 92 | 92 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | /** |
| 98 | 98 | * should be deleted dead code ? |
| 99 | 99 | */ |
| 100 | - if($request->session()->has('wiki_callback')){ |
|
| 100 | + if ($request->session()->has('wiki_callback')) { |
|
| 101 | 101 | $user->wiki_token = $request->session()->get('wiki_token'); |
| 102 | 102 | $user->save(); |
| 103 | 103 | $callback = urldecode($request->session()->get('wiki_callback')); |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | public function redirectToProvider(string $provider) |
| 111 | 111 | { |
| 112 | - if(request()->session()->has('wiki_token')) { |
|
| 112 | + if (request()->session()->has('wiki_token')) { |
|
| 113 | 113 | session()->reflash(); |
| 114 | 114 | } |
| 115 | 115 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK')]); |
| 116 | - if($provider === 'twitter'){ |
|
| 116 | + if ($provider === 'twitter') { |
|
| 117 | 117 | return Socialite::driver($provider)->redirect(); |
| 118 | 118 | } |
| 119 | 119 | return Socialite::driver($provider)->redirectUrl(config('services.'.$provider.'.redirect'))->redirect(); |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | $user->save(); |
| 131 | 131 | $this->guard()->login($user); |
| 132 | 132 | |
| 133 | - if($user->context_id !== null){ |
|
| 133 | + if ($user->context_id !== null) { |
|
| 134 | 134 | $user->wiki_token = $request->session()->get('wiki_token'); |
| 135 | 135 | $user->save(); |
| 136 | 136 | $callback = urldecode($request->session()->get('wiki_callback')); |
| 137 | 137 | return redirect($callback); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if(session()->has('sso')){ |
|
| 140 | + if (session()->has('sso')) { |
|
| 141 | 141 | $sso = session()->get('sso'); |
| 142 | 142 | $sig = session()->get('sig'); |
| 143 | 143 | $wikiCode = session()->get('wikiCode'); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | return redirect()->route('wizard.profile'); |
| 149 | - }catch (ValidationException $e) { |
|
| 149 | + } catch (ValidationException $e) { |
|
| 150 | 150 | $attributes = $e->validator->attributes(); |
| 151 | 151 | $attributes['provider'] = $provider; |
| 152 | 152 | return redirect()->route('register-social-network') |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function showLoginForm(Request $request) |
| 27 | 27 | { |
| 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 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | protected function loggedOut(Request $request) |
| 53 | 53 | { |
| 54 | 54 | $request->session()->reflash(); |
| 55 | - if($request->session()->has('should_attach_to_organization')){ |
|
| 55 | + if ($request->session()->has('should_attach_to_organization')) { |
|
| 56 | 56 | $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect'); |
| 57 | 57 | return $request->wantsJson() |
| 58 | 58 | ? new Response('', 204) |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | $user->save(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if($user->context_id === null){ |
|
| 71 | + if ($user->context_id === null) { |
|
| 72 | 72 | return redirect()->route('wizard.profile'); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if($request->session()->has('sso')){ |
|
| 76 | - if(!$user->hasVerifiedEmail()){ |
|
| 75 | + if ($request->session()->has('sso')) { |
|
| 76 | + if (!$user->hasVerifiedEmail()) { |
|
| 77 | 77 | $request->session()->flash('from_forum', true); |
| 78 | 78 | return redirect()->route('email.verify'); |
| 79 | 79 | } |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | return redirect($wikiCode.'/neayi/discourse/sso?sso='.$sso.'&sig='.$sig); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if($request->session()->has('wiki_callback')){ |
|
| 86 | + if ($request->session()->has('wiki_callback')) { |
|
| 87 | 87 | $user->wiki_token = $request->session()->get('wiki_token'); |
| 88 | 88 | $user->save(); |
| 89 | 89 | $callback = urldecode($request->session()->get('wiki_callback')); |
| 90 | - if(!$user->hasVerifiedEmail()){ |
|
| 90 | + if (!$user->hasVerifiedEmail()) { |
|
| 91 | 91 | return redirect()->route('verification.notice'); |
| 92 | 92 | } |
| 93 | 93 | return redirect($callback); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | public function redirectToProvider(string $provider) |
| 100 | 100 | { |
| 101 | - if($provider === 'twitter'){ |
|
| 101 | + if ($provider === 'twitter') { |
|
| 102 | 102 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK_LOGIN')]); |
| 103 | 103 | return Socialite::driver($provider)->redirect(); |
| 104 | 104 | } |