Added ability to use both 2FA methods at the same time

This commit is contained in:
Will Browning
2025-09-30 15:02:33 +01:00
parent af10811bdc
commit 7763367f18
32 changed files with 1160 additions and 947 deletions

View File

@@ -7,7 +7,6 @@ use App\Http\Resources\PersonalAccessTokenResource;
use App\Jobs\DeleteAccount;
use Illuminate\Http\Request;
use Inertia\Inertia;
use LaravelWebauthn\Facades\Webauthn;
class SettingController extends Controller
{
@@ -43,16 +42,16 @@ class SettingController extends Controller
user()->two_factor_secret
);
// User has either webauthn or TOTP 2FA enabled
$hasTwoFactor = Webauthn::enabled(user()) || user()->two_factor_enabled;
// User has TOTP 2FA enabled
$alreadyHasTotpEnabled = user()->two_factor_enabled;
return Inertia::render('Settings/Security', [
'authSecret' => $hasTwoFactor ? null : user()->two_factor_secret,
'qrCode' => $hasTwoFactor ? null : $qrCode,
'authSecret' => $alreadyHasTotpEnabled ? null : user()->two_factor_secret,
'qrCode' => $alreadyHasTotpEnabled ? null : $qrCode,
'regeneratedBackupCode' => $request->session()->get('regeneratedBackupCode', null),
'backupCode' => $request->session()->get('backupCode', null),
'twoFactorEnabled' => user()->two_factor_enabled,
'webauthnEnabled' => Webauthn::enabled(user()),
'initialTwoFactorEnabled' => user()->two_factor_enabled,
'initialWebauthnEnabled' => user()->webauthn_enabled,
'initialKeys' => user()->webauthnKeys()->latest()->select(['id', 'name', 'enabled', 'created_at'])->get()->values(),
]);
}