protected const SETUP_SECRET_SESSION_KEY = 'mfa-setup-backup-codes';
/**
- * Show a view that generates and displays backup codes
+ * Show a view that generates and displays backup codes.
*/
public function generate(BackupCodeService $codeService)
{
$downloadUrl = 'data:application/octet-stream;base64,' . base64_encode(implode("\n\n", $codes));
return view('mfa.backup-codes-generate', [
- 'codes' => $codes,
+ 'codes' => $codes,
'downloadUrl' => $downloadUrl,
]);
}
/**
* Confirm the setup of backup codes, storing them against the user.
+ *
* @throws Exception
*/
public function confirm()
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');
}
/**
* Verify the MFA method submission on check.
+ *
* @throws NotFoundException
* @throws ValidationException
*/
if (!$codeService->inputCodeExistsInSet($value, $codes)) {
$fail(trans('validation.backup_codes'));
}
- }
- ]
+ },
+ ],
]);
$updatedCodes = $codeService->removeInputCodeFromSet($request->get('code'), $codes);