feat: implement mutual exclusion and warnings between Google Authenticator and Email 2FA

This commit is contained in:
2026-05-21 21:48:12 +07:00
parent 0d083765ff
commit 4741a2dff2
38 changed files with 151 additions and 122 deletions
+13 -3
View File
@@ -80,6 +80,7 @@ class TwoFactorController extends Controller
$user->update([
'two_factor_confirmed_at' => now(),
'two_factor_recovery_codes' => json_encode($recoveryCodes->toArray()),
'email_2fa_enabled' => false, // Automatically disable Email 2FA
]);
return back()->with('success', 'Two-Factor Authentication has been enabled successfully.');
@@ -114,9 +115,18 @@ class TwoFactorController extends Controller
]);
$user = auth()->user();
$user->update([
'email_2fa_enabled' => $request->enabled,
]);
if ($request->enabled) {
$user->update([
'email_2fa_enabled' => true,
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
'two_factor_confirmed_at' => null,
]);
} else {
$user->update([
'email_2fa_enabled' => false,
]);
}
$status = $request->enabled ? 'enabled' : 'disabled';
return back()->with('success', "Two-Factor Authentication via Email has been {$status} successfully.");