From 3e242aaca6c71a4aec6b42e515894d4206399e85 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 17 Aug 2019 06:35:45 +0200 Subject: [PATCH] Clean up login controller. --- app/Http/Controllers/Auth/LoginController.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 96176032b2..f9e43bca2f 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Auth; use Adldap; use DB; use FireflyIII\Http\Controllers\Controller; -use FireflyIII\User; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; use Log; @@ -83,34 +82,32 @@ class LoginController extends Controller } $this->validateLogin($request); + /** Copied directly from AuthenticatesUsers, but with logging added: */ // If the class is using the ThrottlesLogins trait, we can automatically throttle // the login attempts for this application. We'll key this by the username and // the IP address of the client making these requests into this application. - if ($this->hasTooManyLoginAttempts($request)) { + if (method_exists($this, 'hasTooManyLoginAttempts') && $this->hasTooManyLoginAttempts($request)) { Log::channel('audit')->info(sprintf('Login for user "%s" was locked out.', $request->get('email'))); $this->fireLockoutEvent($request); return $this->sendLockoutResponse($request); } + /** Copied directly from AuthenticatesUsers, but with logging added: */ if ($this->attemptLogin($request)) { Log::channel('audit')->info(sprintf('User "%s" has been logged in.', $request->get('email'))); - // user is logged in. Save in session if the user requested session to be remembered: - $request->session()->put('remember_login', $request->filled('remember')); - Log::debug(sprintf('Redirect after login is %s.', $this->redirectPath())); - $response = $this->sendLoginResponse($request); - Log::debug(sprintf('Response Location header: %s', $response->headers->get('location'))); - - return $response; + return $this->sendLoginResponse($request); } + /** Copied directly from AuthenticatesUsers, but with logging added: */ // If the login attempt was unsuccessful we will increment the number of attempts // to login and redirect the user back to the login form. Of course, when this // user surpasses their maximum number of attempts they will get locked out. $this->incrementLoginAttempts($request); Log::channel('audit')->info(sprintf('Login attempt for user "%s" failed.', $request->get('email'))); + return $this->sendFailedLoginResponse($request); }