mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00
Check against 2fa backup codes too in Login
(#1366)
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
This commit is contained in:
parent
fd49f472c3
commit
e5cba893e4
@ -57,11 +57,22 @@ class Login extends BaseLogin
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isValidToken = false;
|
||||||
|
if (strlen($token) === $this->google2FA->getOneTimePasswordLength()) {
|
||||||
$isValidToken = $this->google2FA->verifyKey(
|
$isValidToken = $this->google2FA->verifyKey(
|
||||||
$user->totp_secret,
|
$user->totp_secret,
|
||||||
$token,
|
$token,
|
||||||
Config::integer('panel.auth.2fa.window'),
|
Config::integer('panel.auth.2fa.window'),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
foreach ($user->recoveryTokens as $recoveryToken) {
|
||||||
|
if (password_verify($token, $recoveryToken->token)) {
|
||||||
|
$isValidToken = true;
|
||||||
|
$recoveryToken->delete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$isValidToken) {
|
if (!$isValidToken) {
|
||||||
// Buffer to prevent bruteforce
|
// Buffer to prevent bruteforce
|
||||||
@ -108,7 +119,9 @@ class Login extends BaseLogin
|
|||||||
{
|
{
|
||||||
return TextInput::make('2fa')
|
return TextInput::make('2fa')
|
||||||
->label(trans('auth.two-factor-code'))
|
->label(trans('auth.two-factor-code'))
|
||||||
->hidden(fn () => !$this->verifyTwoFactor)
|
->hintIcon('tabler-question-mark')
|
||||||
|
->hintIconTooltip(trans('auth.two-factor-hint'))
|
||||||
|
->visible(fn () => $this->verifyTwoFactor)
|
||||||
->required()
|
->required()
|
||||||
->live();
|
->live();
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ return [
|
|||||||
'failed' => 'These credentials do not match our records.',
|
'failed' => 'These credentials do not match our records.',
|
||||||
'failed-two-factor' => 'Incorrect 2FA Code',
|
'failed-two-factor' => 'Incorrect 2FA Code',
|
||||||
'two-factor-code' => 'Two Factor Code',
|
'two-factor-code' => 'Two Factor Code',
|
||||||
|
'two-factor-hint' => 'You may use backup codes if you lost access to your device.',
|
||||||
'password' => 'The provided password is incorrect.',
|
'password' => 'The provided password is incorrect.',
|
||||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||||
'2fa_must_be_enabled' => 'The administrator has required that 2-Factor Authentication must be enabled for your account in order to use the Panel.',
|
'2fa_must_be_enabled' => 'The administrator has required that 2-Factor Authentication must be enabled for your account in order to use the Panel.',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user