Open sunscreem opened 8 years ago
Very happy. Not in vain tried
Thanks for this solution!
I slightly modified it:
public function showLoginForm()
{
// If already logged in, redirect to the admin panel
if (Auth::guard('admin')->user()) {
return redirect()->intended($this->redirectPath());
}
// Save the intended to visit page in the session
$previous_url = Session::get('_previous.url');
$previous_url = htmlspecialchars($previous_url);
if ($previous_url != route('admin.login')) {
Session::put('url.intended', $previous_url);
}
return view('admin.auth.login');
}
protected function handleUserWasAuthenticated(Request $request, $throttles)
{
if ($throttles) {
$this->clearLoginAttempts($request);
}
if (method_exists($this, 'authenticated')) {
return $this->authenticated($request, Auth::guard($this->getGuard())->user());
}
// Will return user to the previous page (intended to visit)
return redirect()->intended(Session::pull('url.intended', $this->redirectPath()));
}
This saved me a heap of time on a recent project. Even got it working with a modal for the log in form.
:)