X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2ed031712918313b50483d22cf6735aed227dc06..refs/pull/2716/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..01255f466 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -3,11 +3,13 @@ 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\Facades\Theme; use BookStack\Http\Controllers\Controller; +use BookStack\Theming\ThemeEvents; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; @@ -46,7 +48,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 +78,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 +152,8 @@ class LoginController extends Controller } } + Theme::dispatch(ThemeEvents::AUTH_LOGIN, auth()->getDefaultDriver(), $user); + $this->logActivity(ActivityType::AUTH_LOGIN, $user); return redirect()->intended($this->redirectPath()); } @@ -191,5 +198,4 @@ class LoginController extends Controller return redirect('/login'); } - }