diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 548ff5cb6..b282bda66 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -105,7 +105,7 @@ class LoginController extends Controller // Validate the cookie data if (json_last_error() === JSON_ERROR_NONE && isset($cookieData['user_id'], $cookieData['token'], $cookieData['expires_at']) && - (int)$cookieData['user_id'] === (int)$user->id && + (int) $cookieData['user_id'] === (int) $user->id && time() <= $cookieData['expires_at']) { // Cookie is valid - mark 2FA as passed @@ -120,7 +120,7 @@ class LoginController extends Controller } } catch (\Exception $e) { \Log::error('Login - Error processing trusted device cookie', [ - 'error' => $e->getMessage() + 'error' => $e->getMessage(), ]); } } @@ -197,7 +197,7 @@ class LoginController extends Controller 'expires_at' => $cookieData['expires_at'], 'current_time' => time(), 'remaining_seconds' => $remainingSeconds, - 'remaining_minutes' => $remainingMinutes + 'remaining_minutes' => $remainingMinutes, ]); // Only preserve the cookie if it hasn't expired yet @@ -225,7 +225,7 @@ class LoginController extends Controller } } catch (\Exception $e) { \Log::error('Logout - Error Processing Cookie', [ - 'error' => $e->getMessage() + 'error' => $e->getMessage(), ]); } } diff --git a/app/Http/Controllers/PasswordSecurityController.php b/app/Http/Controllers/PasswordSecurityController.php index 26011d7fb..d5c2f2e25 100644 --- a/app/Http/Controllers/PasswordSecurityController.php +++ b/app/Http/Controllers/PasswordSecurityController.php @@ -197,7 +197,7 @@ class PasswordSecurityController extends Controller 'domain' => '', 'secure' => request()->secure(), 'httponly' => false, - 'samesite' => 'Lax' + 'samesite' => 'Lax', ] ); @@ -243,6 +243,7 @@ class PasswordSecurityController extends Controller // Create a response with the rendered content instead of directly outputting $content = app('smarty.view')->fetch($theme.'/2fa_verify.tpl'); + return response($content); } diff --git a/app/Http/Middleware/Google2FAMiddleware.php b/app/Http/Middleware/Google2FAMiddleware.php index 04a82492d..869a08861 100644 --- a/app/Http/Middleware/Google2FAMiddleware.php +++ b/app/Http/Middleware/Google2FAMiddleware.php @@ -25,7 +25,7 @@ class Google2FAMiddleware // Check if all required fields exist if (isset($cookieData['user_id'], $cookieData['token'], $cookieData['expires_at'])) { // Check if cookie user ID matches authenticated user - if ((int)$cookieData['user_id'] === (int)auth()->id()) { + if ((int) $cookieData['user_id'] === (int) auth()->id()) { // Check if cookie is not expired if (time() <= $cookieData['expires_at']) { // Set the session variables for 2FA authentication diff --git a/app/Http/Middleware/TrustedDevice2FAMiddleware.php b/app/Http/Middleware/TrustedDevice2FAMiddleware.php index bc6dd34f3..b7ace2a7b 100644 --- a/app/Http/Middleware/TrustedDevice2FAMiddleware.php +++ b/app/Http/Middleware/TrustedDevice2FAMiddleware.php @@ -10,10 +10,6 @@ class TrustedDevice2FAMiddleware { /** * Handle an incoming request. - * - * @param Request $request - * @param Closure $next - * @return mixed */ public function handle(Request $request, Closure $next): mixed { @@ -27,7 +23,7 @@ class TrustedDevice2FAMiddleware // If cookie data is valid and user matches if (json_last_error() === JSON_ERROR_NONE && isset($cookieData['user_id'], $cookieData['token'], $cookieData['expires_at']) && - (int)$cookieData['user_id'] === (int)auth()->id() && + (int) $cookieData['user_id'] === (int) auth()->id() && time() <= $cookieData['expires_at']) { // Mark this user's session as having passed 2FA @@ -36,7 +32,7 @@ class TrustedDevice2FAMiddleware } } catch (\Exception $e) { Log::error('TrustedDevice2FAMiddleware - Error processing cookie', [ - 'error' => $e->getMessage() + 'error' => $e->getMessage(), ]); } } @@ -76,14 +72,14 @@ class TrustedDevice2FAMiddleware 'domain' => '', 'secure' => $request->secure(), 'httponly' => false, - 'samesite' => 'Lax' + 'samesite' => 'Lax', ]); // Keep in session for backup access $request->session()->put('2fa_trusted_device_value', $cookieValue); } catch (\Exception $e) { Log::error('TrustedDevice2FAMiddleware - Error setting cookie', [ - 'error' => $e->getMessage() + 'error' => $e->getMessage(), ]); } } diff --git a/app/Support/Google2FAAuthenticator.php b/app/Support/Google2FAAuthenticator.php index 57f4d7604..6cdc6a5db 100644 --- a/app/Support/Google2FAAuthenticator.php +++ b/app/Support/Google2FAAuthenticator.php @@ -35,17 +35,17 @@ class Google2FAAuthenticator extends Authenticator try { $data = @json_decode($cookie, true); - if (!is_array($data)) { + if (! is_array($data)) { return false; } // Validate all required fields - if (!isset($data['user_id'], $data['token'], $data['expires_at'])) { + if (! isset($data['user_id'], $data['token'], $data['expires_at'])) { return false; } // Ensure the user ID matches - if ((int)$data['user_id'] !== (int)$this->getUser()->id) { + if ((int) $data['user_id'] !== (int) $this->getUser()->id) { return false; } @@ -148,7 +148,7 @@ class Google2FAAuthenticator extends Authenticator if (json_last_error() === JSON_ERROR_NONE && isset($cookieData['user_id'], $cookieData['token'], $cookieData['expires_at']) && - (int)$cookieData['user_id'] === (int)auth()->id() && + (int) $cookieData['user_id'] === (int) auth()->id() && time() <= $cookieData['expires_at']) { // If we have a valid cookie, force-disable 2FA