MfaValue::upsertWithValue($this->currentOrLastAttemptedUser(), MfaValue::METHOD_BACKUP_CODES, json_encode($codes));
$this->logActivity(ActivityType::MFA_SETUP_METHOD, 'backup-codes');
+
+ if (!auth()->check()) {
+ $this->showSuccessNotification(trans('auth.mfa_setup_login_notification'));
+ return redirect('/login');
+ }
+
return redirect('/mfa/setup');
}
session()->remove(static::SETUP_SECRET_SESSION_KEY);
$this->logActivity(ActivityType::MFA_SETUP_METHOD, 'totp');
+ if (!auth()->check()) {
+ $this->showSuccessNotification(trans('auth.mfa_setup_login_notification'));
+ return redirect('/login');
+ }
+
return redirect('/mfa/setup');
}
return $next($request);
}
- return redirect()->guest(url('/login'));
+ return redirect()->to(url('/login'));
}
}
// Multi-factor Authentication
'mfa_setup' => 'Setup Multi-Factor Authentication',
'mfa_setup_desc' => 'Setup multi-factor authentication as an extra layer of security for your user account.',
- 'mfa_setup_configured' => 'Already Configured',
+ 'mfa_setup_configured' => 'Already configured',
'mfa_setup_reconfigure' => 'Reconfigure',
'mfa_setup_remove_confirmation' => 'Are you sure you want to remove this multi-factor authentication method?',
'mfa_setup_action' => 'Setup',
'mfa_verify_backup_code_desc' => 'Enter one of your remaining backup codes below:',
'mfa_verify_backup_code_enter_here' => 'Enter backup code here',
'mfa_verify_totp_desc' => 'Enter the code, generated using your mobile app, below:',
+ 'mfa_setup_login_notification' => 'Multi-factor method configured, Please now login again using the configured method.',
];
\ No newline at end of file
$login->assertRedirectedTo('http://localhost');
}
+ public function test_login_intended_redirect_does_not_factor_mfa_routes()
+ {
+ $this->get('/books')->assertRedirectedTo('/login');
+ $this->get('/mfa/setup')->assertRedirectedTo('/login');
+ $login = $this->post('/login', ['email' => '
[email protected]', 'password' => 'password']);
+ $login->assertRedirectedTo('/books');
+ }
+
public function test_login_authenticates_admins_on_all_guards()
{
$resp->assertElementContains('a[href$="/mfa/setup"]', 'Configure');
$this->get('/mfa/backup_codes/generate');
- $this->followingRedirects()->post('/mfa/backup_codes/confirm');
+ $resp = $this->post('/mfa/backup_codes/confirm');
+ $resp->assertRedirect('/login');
$this->assertDatabaseHas('mfa_values', [
'user_id' => $user->id,
]);
+ $resp = $this->get('/login');
+ $resp->assertSeeText('Multi-factor method configured, Please now login again using the configured method.');
+
$resp = $this->followingRedirects()->post('/login', [
'email' => $user->email,
'password' => 'password',