From 049f97ced68b01d09a6cea6a2b6474f08932b9a7 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Wed, 8 May 2024 11:13:27 -0400 Subject: [PATCH] Add TwoFactorAuthenticationController with code confirmation methods --- .../TwoFactorAuthenticationController.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/Http/Controllers/TwoFactorAuthenticationController.php diff --git a/src/Http/Controllers/TwoFactorAuthenticationController.php b/src/Http/Controllers/TwoFactorAuthenticationController.php new file mode 100644 index 0000000..352bd52 --- /dev/null +++ b/src/Http/Controllers/TwoFactorAuthenticationController.php @@ -0,0 +1,42 @@ +google2fa = $google2fa; + } + + public function confirmAuthenticationCode(Request $request) + { + $user = $request->user(); + $valid = $this->google2fa->verifyKey($user->two_factor_secret, $request->code); + + if ($valid) { + // Handle successful authentication + } else { + // Handle failed authentication + } + } + + public function confirmRecoveryCode(Request $request) + { + $user = $request->user(); + $recoveryCodes = $user->two_factor_recovery_codes; + $valid = in_array($request->code, $recoveryCodes); + + if ($valid) { + // Handle successful recovery code confirmation + } else { + // Handle failed recovery code confirmation + } + } +}