From 3ae70efc14d47700721406aad1a0fdf6891bff3b Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sun, 22 May 2022 17:26:32 -0400 Subject: [PATCH] Use existing method to handle the login --- app/Http/Controllers/Auth/LoginController.php | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 69734ab8b..b3ee4b2a4 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -67,27 +67,21 @@ class LoginController extends AbstractLoginController $this->sendFailedLoginResponse($request, $user); } - if ($user->use_totp) { - $token = Str::random(64); - - $request->session()->put('auth_confirmation_token', [ - 'user_id' => $user->id, - 'token_value' => $token, - 'expires_at' => CarbonImmutable::now()->addMinutes(5), - ]); - - return new JsonResponse([ - 'data' => [ - 'complete' => false, - 'confirmation_token' => $token, - ], - ]); + if (!$user->use_totp) { + return $this->sendLoginResponse($user, $request); } - $this->auth->guard()->login($user, true); + $request->session()->put('auth_confirmation_token', [ + 'user_id' => $user->id, + 'token_value' => $token = Str::random(64), + 'expires_at' => CarbonImmutable::now()->addMinutes(5), + ]); - $request->session()->regenerate(); - - return $this->sendLoginResponse($user, $request); + return new JsonResponse([ + 'data' => [ + 'complete' => false, + 'confirmation_token' => $token, + ], + ]); } }