@@ -320,7 +320,7 @@ |
||
320 | 320 | 'real_name' => $real_name, |
321 | 321 | 'email' => $email, |
322 | 322 | 'password' => password_hash($password, PASSWORD_DEFAULT), |
323 | - 'secret' => $secret, |
|
323 | + 'secret' => $secret, |
|
324 | 324 | ]); |
325 | 325 | |
326 | 326 | $user_id = DB::lastInsertId(); |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | $language = Validator::parsedBody($request)->string('language'); |
68 | 68 | $real_name = Validator::parsedBody($request)->string('real_name'); |
69 | 69 | $password = Validator::parsedBody($request)->string('password'); |
70 | - $secret = Validator::parsedBody($request)->string('secret'); |
|
70 | + $secret = Validator::parsedBody($request)->string('secret'); |
|
71 | 71 | $time_zone = Validator::parsedBody($request)->string('timezone'); |
72 | 72 | $user_name = Validator::parsedBody($request)->string('user_name'); |
73 | 73 | $visible_online = Validator::parsedBody($request)->boolean('visible-online', false); |
74 | - $status_mfa = Validator::parsedBody($request)->boolean('status-mfa', '0'); |
|
74 | + $status_mfa = Validator::parsedBody($request)->boolean('status-mfa', '0'); |
|
75 | 75 | |
76 | 76 | // Change the password |
77 | 77 | if ($password !== '') { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $user->setPreference(UserInterface::PREF_LANGUAGE, $language); |
105 | 105 | $user->setPreference(UserInterface::PREF_TIME_ZONE, $time_zone); |
106 | 106 | $user->setPreference(UserInterface::PREF_IS_VISIBLE_ONLINE, (string) $visible_online); |
107 | - $user->setPreference(UserInterface::PREF_IS_STATUS_MFA, (string) $status_mfa); |
|
107 | + $user->setPreference(UserInterface::PREF_IS_STATUS_MFA, (string) $status_mfa); |
|
108 | 108 | |
109 | 109 | if ($tree instanceof Tree) { |
110 | 110 | $default_xref = Validator::parsedBody($request)->string('default-xref'); |
@@ -409,7 +409,7 @@ |
||
409 | 409 | $admin = $this->user_service->create($data['wtuser'], $data['wtname'], $data['wtemail'], $data['wtpass'], $data['wtsecret']); |
410 | 410 | $admin->setPreference(UserInterface::PREF_LANGUAGE, $data['lang']); |
411 | 411 | $admin->setPreference(UserInterface::PREF_IS_VISIBLE_ONLINE, '1'); |
412 | - $admin->setPreference(UserInterface::PREF_IS_STATUS_MFA, '0'); |
|
412 | + $admin->setPreference(UserInterface::PREF_IS_STATUS_MFA, '0'); |
|
413 | 413 | } else { |
414 | 414 | $admin->setPassword($_POST['wtpass']); |
415 | 415 | } |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $real_name = Validator::parsedBody($request)->string('real_name'); |
60 | 60 | $email = Validator::parsedBody($request)->string('email'); |
61 | 61 | $password = Validator::parsedBody($request)->string('password'); |
62 | - $secret = ""; |
|
62 | + $secret = ""; |
|
63 | 63 | |
64 | 64 | $errors = false; |
65 | 65 |
@@ -96,7 +96,7 @@ |
||
96 | 96 | $password = Validator::parsedBody($request)->string('password'); |
97 | 97 | $realname = Validator::parsedBody($request)->string('realname'); |
98 | 98 | $username = Validator::parsedBody($request)->string('username'); |
99 | - $secret = Validator::parsedBody($request)->string('secret'); |
|
99 | + $secret = Validator::parsedBody($request)->string('secret'); |
|
100 | 100 | |
101 | 101 | try { |
102 | 102 | if ($this->captcha_service->isRobot($request)) { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $default_url = route(HomePage::class); |
70 | 70 | $username = Validator::parsedBody($request)->string('username'); |
71 | 71 | $password = Validator::parsedBody($request)->string('password'); |
72 | - $code2fa = Validator::parsedBody($request)->string('code2fa'); |
|
72 | + $code2fa = Validator::parsedBody($request)->string('code2fa'); |
|
73 | 73 | $url = Validator::parsedBody($request)->isLocalUrl()->string('url', $default_url); |
74 | 74 | |
75 | 75 | try { |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | throw new Exception(I18N::translate('This account has not been approved. Please wait for an administrator to approve it.')); |
133 | 133 | } |
134 | 134 | if ($user->getPreference(UserInterface::PREF_IS_STATUS_MFA) !== '') { |
135 | - # covers scenario where 2fa not enabled by user |
|
136 | - if($code2fa != '') { |
|
135 | + # covers scenario where 2fa not enabled by user |
|
136 | + if($code2fa != '') { |
|
137 | 137 | if (!$user->check2FAcode($code2fa)) { |
138 | 138 | throw new Exception(I18N::translate('2FA code does not match. Please try again.')); |
139 | 139 | } |
140 | - } |
|
141 | - else { |
|
140 | + } |
|
141 | + else { |
|
142 | 142 | throw new Exception(I18N::translate('2FA code must be entered as you have 2FA authentication enabled. Please try again.')); |
143 | - } |
|
143 | + } |
|
144 | 144 | } |
145 | 145 | Auth::login($user); |
146 | 146 | Log::addAuthenticationLog('Login: ' . Auth::user()->userName() . '/' . Auth::user()->realName()); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $real_name = Validator::parsedBody($request)->string('real_name'); |
76 | 76 | $email = Validator::parsedBody($request)->string('email'); |
77 | 77 | $password = Validator::parsedBody($request)->string('password'); |
78 | - $secret = Validator::parsedBody($request)->string('secret'); |
|
78 | + $secret = Validator::parsedBody($request)->string('secret'); |
|
79 | 79 | $theme = Validator::parsedBody($request)->string('theme'); |
80 | 80 | $language = Validator::parsedBody($request)->string('language'); |
81 | 81 | $timezone = Validator::parsedBody($request)->string('timezone'); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $canadmin = Validator::parsedBody($request)->boolean('canadmin', false); |
86 | 86 | $visible_online = Validator::parsedBody($request)->boolean('visible-online', false); |
87 | 87 | $verified = Validator::parsedBody($request)->boolean('verified', false); |
88 | - $status_mfa = Validator::parsedBody($request)->boolean('status-mfa', false); |
|
88 | + $status_mfa = Validator::parsedBody($request)->boolean('status-mfa', false); |
|
89 | 89 | $approved = Validator::parsedBody($request)->boolean('approved', false); |
90 | 90 | |
91 | 91 | $edit_user = $this->user_service->find($user_id); |
@@ -278,24 +278,24 @@ |
||
278 | 278 | return $this; |
279 | 279 | } |
280 | 280 | |
281 | - /** |
|
282 | - * Validate a supplied 2fa code |
|
283 | - * |
|
284 | - * @param string $code2fa |
|
285 | - * |
|
286 | - * @return bool |
|
287 | - */ |
|
288 | - public function check2facode(string $code2fa): bool |
|
289 | - { |
|
290 | - $secret = DB::table('user') |
|
291 | - ->where('user_id', '=', $this->id()) |
|
292 | - ->value('secret'); |
|
293 | - $google2fa = new Google2FA; |
|
294 | - if($google2fa->verifyKey($secret, $code2fa)) { |
|
295 | - return true; |
|
296 | - } |
|
297 | - return false; |
|
298 | - } |
|
281 | + /** |
|
282 | + * Validate a supplied 2fa code |
|
283 | + * |
|
284 | + * @param string $code2fa |
|
285 | + * |
|
286 | + * @return bool |
|
287 | + */ |
|
288 | + public function check2facode(string $code2fa): bool |
|
289 | + { |
|
290 | + $secret = DB::table('user') |
|
291 | + ->where('user_id', '=', $this->id()) |
|
292 | + ->value('secret'); |
|
293 | + $google2fa = new Google2FA; |
|
294 | + if($google2fa->verifyKey($secret, $code2fa)) { |
|
295 | + return true; |
|
296 | + } |
|
297 | + return false; |
|
298 | + } |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * A closure which will create an object from a database row. |