canManageTwoFactor = Features::canManageTwoFactorAuthentication(); if ($this->canManageTwoFactor) { if (Fortify::confirmsTwoFactorAuthentication() && is_null(auth()->user()->two_factor_confirmed_at)) { $disableTwoFactorAuthentication(auth()->user()); } $this->twoFactorEnabled = auth()->user()->hasEnabledTwoFactorAuthentication(); $this->requiresConfirmation = Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm'); } $this->canManagePasskeys = Features::canManagePasskeys(); if ($this->canManagePasskeys) { $this->loadPasskeys(); } } /** * Update the password for the currently authenticated user. */ public function updatePassword(): void { try { $validated = $this->validate([ 'current_password' => $this->currentPasswordRules(), 'password' => $this->passwordRules(), ]); } catch (ValidationException $e) { $this->reset('current_password', 'password', 'password_confirmation'); throw $e; } Auth::user()->update([ 'password' => $validated['password'], ]); $this->reset('current_password', 'password', 'password_confirmation'); Flux::toast(variant: 'success', text: __('Password updated.')); } /** * Load the user's passkeys. */ public function loadPasskeys(): void { $this->passkeys = auth()->user()->passkeys() ->select(['id', 'name', 'credential', 'created_at', 'last_used_at']) ->latest() ->get() ->map(fn ($passkey) => [ 'id' => $passkey->id, 'name' => $passkey->name, 'authenticator' => $passkey->authenticator, 'created_at_diff' => $passkey->created_at->diffForHumans(), 'last_used_at_diff' => $passkey->last_used_at?->diffForHumans(), ]) ->toArray(); } /** * Show the delete confirmation modal. */ public function confirmDelete(int $passkeyId): void { $passkey = auth()->user()->passkeys()->findOrFail($passkeyId); $this->deletingPasskeyId = $passkey->id; $this->deletingPasskeyName = $passkey->name; $this->showDeleteModal = true; } /** * Delete the passkey. */ public function deletePasskey(DeletePasskey $deletePasskey): void { if (! $this->deletingPasskeyId) { return; } $passkey = auth()->user()->passkeys()->findOrFail($this->deletingPasskeyId); $deletePasskey(auth()->user(), $passkey); $this->closeDeleteModal(); $this->loadPasskeys(); } /** * Close the delete confirmation modal. */ public function closeDeleteModal(): void { $this->showDeleteModal = false; $this->deletingPasskeyId = null; $this->deletingPasskeyName = ''; } /** * Handle the two-factor authentication enabled event. */ #[On('two-factor-enabled')] public function onTwoFactorEnabled(): void { $this->twoFactorEnabled = true; } /** * Disable two-factor authentication for the user. */ public function disable(DisableTwoFactorAuthentication $disableTwoFactorAuthentication): void { $disableTwoFactorAuthentication(auth()->user()); $this->twoFactorEnabled = false; } }; ?>
@include('partials.settings-heading') {{ __('Security settings') }}
{{ __('Save') }}
@if ($canManageTwoFactor)
{{ __('Two-factor authentication') }} {{ __('Manage your two-factor authentication settings') }}
@if ($twoFactorEnabled)
{{ __('You will be prompted for a secure, random pin during login, which you can retrieve from the TOTP-supported application on your phone.') }}
{{ __('Disable 2FA') }}
@else
{{ __('When you enable two-factor authentication, you will be prompted for a secure pin during login. This pin can be retrieved from a TOTP-supported application on your phone.') }} {{ __('Enable 2FA') }}
@endif
@endif @if ($canManagePasskeys)
{{ __('Passkeys') }} {{ __('Manage your passkeys for passwordless sign-in') }}
@forelse ($passkeys as $passkey)

{{ $passkey['name'] }}

@if ($passkey['authenticator']) {{ $passkey['authenticator'] }} @endif

{{ __('Added :time', ['time' => $passkey['created_at_diff']]) }} @if ($passkey['last_used_at_diff']) / {{ __('Last used :time', ['time' => $passkey['last_used_at_diff']]) }} @endif

@empty

{{ __('No passkeys yet') }}

{{ __('Add a passkey to sign in without a password') }}
@endforelse
@endif
{{ __('Remove passkey') }} {{ __('Are you sure you want to remove the passkey ":name"? You will no longer be able to use it to sign in.', ['name' => $deletingPasskeyName]) }}
{{ __('Cancel') }} {{ __('Remove passkey') }}