X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2ed031712918313b50483d22cf6735aed227dc06..refs/pull/2416/head:/app/Http/Controllers/Auth/LoginController.php diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index cd7a4db32..1252e6217 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -3,10 +3,10 @@ namespace BookStack\Http\Controllers\Auth; use Activity; +use BookStack\Actions\ActivityType; use BookStack\Auth\Access\SocialAuthService; use BookStack\Exceptions\LoginAttemptEmailNeededException; use BookStack\Exceptions\LoginAttemptException; -use BookStack\Exceptions\UserRegistrationException; use BookStack\Http\Controllers\Controller; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; @@ -46,7 +46,6 @@ class LoginController extends Controller $this->socialAuthService = $socialAuthService; $this->redirectPath = url('/'); $this->redirectAfterLogout = url('/http/source.bookstackapp.com/login'); - parent::__construct(); } public function username() @@ -77,9 +76,13 @@ class LoginController extends Controller ]); } + // Store the previous location for redirect after login $previous = url()->previous(''); - if (setting('app-public') && $previous && $previous !== url('/http/source.bookstackapp.com/login')) { - redirect()->setIntendedUrl($previous); + if ($previous && $previous !== url('/http/source.bookstackapp.com/login') && setting('app-public')) { + $isPreviousFromInstance = (strpos($previous, url('/')) === 0); + if ($isPreviousFromInstance) { + redirect()->setIntendedUrl($previous); + } } return view('auth.login', [ @@ -147,6 +150,7 @@ class LoginController extends Controller } } + $this->logActivity(ActivityType::AUTH_LOGIN, $user); return redirect()->intended($this->redirectPath()); }