From 652d2e03ca2129d2747c6f7b6cf0db98c285aa02 Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Thu, 26 Sep 2024 21:16:12 +0300 Subject: [PATCH] Add regenerateCodes method --- .../two-factor-authentication/index.blade.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/resources/views/pages/user/two-factor-authentication/index.blade.php b/resources/views/pages/user/two-factor-authentication/index.blade.php index 9a116e1..17a4559 100644 --- a/resources/views/pages/user/two-factor-authentication/index.blade.php +++ b/resources/views/pages/user/two-factor-authentication/index.blade.php @@ -54,16 +54,22 @@ private function generateCodes(){ return $generateCodesFor(auth()->user()); } + public function regenerateCodes(){ + auth()->user()->forceFill([ + 'two_factor_recovery_codes' => encrypt(json_encode($this->generateCodes())) + ])->save(); + } + public function cancelTwoFactor(){ auth()->user()->forceFill([ 'two_factor_secret' => null, 'two_factor_recovery_codes' => null ])->save(); - + $this->enabled = false; } - #[On('submitCode')] + #[On('submitCode')] public function submitCode($code) { $this->auth_code = $code; @@ -100,7 +106,7 @@ public function disable(){ @volt('user.two-factor-authentication')
-
+
@if($confirmed)

You have enabled two factor authentication.

@@ -108,7 +114,7 @@ public function disable(){ @if($showRecoveryCodes)

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(auth()->user()->two_factor_recovery_codes), true) as $code)
{{ $code }}
@@ -124,7 +130,7 @@ public function disable(){ @else @if(!$enabled) -
+

Two factor authentication disabled.

When you enabled 2FA, you will be prompted for a secure code during authentication. This code can be retrieved from your phone's Google Authenticator application.

@@ -132,14 +138,14 @@ public function disable(){
@else -
+

Finish enabling two factor authentication.

Enable two-factor authentication to receive a secure token from your phone's Google Authenticator during login.

To enable two-factor authentication, scan the QR code or enter the setup key using your phone's authenticator app and provide the OTP code.

-
+