two_factor_confirmed_at)) { app(DisableTwoFactorAuthentication::class)(Auth::user()); } } /** * Enable two factor authentication for the user. * * @return void */ public function enableTwoFactorAuthentication(EnableTwoFactorAuthentication $enable) { if (Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword')) { $this->ensurePasswordIsConfirmed(); } $enable(Auth::user()); $this->showingQrCode = true; if (Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm')) { $this->showingConfirmation = true; } else { $this->showingRecoveryCodes = true; } } /** * Confirm two factor authentication for the user. * * @return void */ public function confirmTwoFactorAuthentication(ConfirmTwoFactorAuthentication $confirm) { if (Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword')) { $this->ensurePasswordIsConfirmed(); } $confirm(Auth::user(), $this->code); $this->showingQrCode = false; $this->showingConfirmation = false; $this->showingRecoveryCodes = true; } /** * Display the user's recovery codes. * * @return void */ public function showRecoveryCodes() { if (Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword')) { $this->ensurePasswordIsConfirmed(); } $this->showingRecoveryCodes = true; } /** * Generate new recovery codes for the user. * * @return void */ public function regenerateRecoveryCodes(GenerateNewRecoveryCodes $generate) { if (Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword')) { $this->ensurePasswordIsConfirmed(); } $generate(Auth::user()); $this->showingRecoveryCodes = true; } /** * Disable two factor authentication for the user. * * @return void */ public function disableTwoFactorAuthentication(DisableTwoFactorAuthentication $disable) { if (Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword')) { $this->ensurePasswordIsConfirmed(); } $disable(Auth::user()); $this->showingQrCode = false; $this->showingConfirmation = false; $this->showingRecoveryCodes = false; } /** * Get the current user of the application. * * @return mixed */ public function getUserProperty() { return Auth::user(); } /** * Determine if two factor authentication is enabled. * * @return bool */ public function getEnabledProperty() { return ! empty($this->user->two_factor_secret); } }; ?> {{ __('Two Factor Authentication') }} {{ __('Add additional security to your account using two factor authentication.') }}

@if ($this->enabled) @if ($showingConfirmation) {{ __('Finish enabling two factor authentication.') }} @else {{ __('You have enabled two factor authentication.') }} @endif @else {{ __('You have not enabled two factor authentication.') }} @endif

{{ __('When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone\'s Google Authenticator application.') }}

@if ($this->enabled) @if ($showingQrCode)

@if ($showingConfirmation) {{ __('To finish enabling two factor authentication, scan the following QR code using your phone\'s authenticator application or enter the setup key and provide the generated OTP code.') }} @else {{ __('Two factor authentication is now enabled. Scan the following QR code using your phone\'s authenticator application or enter the setup key.') }} @endif

{!! $this->user->twoFactorQrCodeSvg() !!}

{{ __('Setup Key') }}: {{ decrypt($this->user->two_factor_secret) }}

@if ($showingConfirmation)
@endif @endif @if ($showingRecoveryCodes)

{{ __('Store these recovery codes in a secure password manager. They can be used to recover access to your account if your two factor authentication device is lost.') }}

@foreach (json_decode(decrypt($this->user->two_factor_recovery_codes), true) as $code)
{{ $code }}
@endforeach
@endif @endif
@if (! $this->enabled) {{ __('Enable') }} @else @if ($showingRecoveryCodes) {{ __('Regenerate Recovery Codes') }} @elseif ($showingConfirmation) {{ __('Confirm') }} @else {{ __('Show Recovery Codes') }} @endif @if ($showingConfirmation) {{ __('Cancel') }} @else {{ __('Disable') }} @endif @endif