mirror of
https://github.com/anonaddy/anonaddy
synced 2026-05-05 06:32:01 +02:00
Added ability to use both 2FA methods at the same time
This commit is contained in:
@@ -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(),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user