Back

Incorrect redirect after login


I have a site with 2 different logins, one for users (I use the default auth) and one for admins, for the admin i'm using a new guard, I added a new middleware and using a new guard called Auth::guard('web_admin')

Everything works fine, for the login I'm using AuthenticatesUser, I set my protected $redirectTo = '/admin/dashboard';

The problem is that some times after login I'm redirected to "/" instead of "/admin/dashboard", the admin is succesfully logged but sometimes it doesn't redirect to the admin dashboard, if after the redirect to "/" I try to open the admin url everything works correct, the admin is logged.

I noticed something, if I open directly the url "/admin" and I get redirected to "/admin/login" the login does redirects me to "/admin/dashboard", but if I first visit "/" and then I open "/admin" and I get redirected to "/admin/login" the login redirects me to "/"

I don't know if even I'm using a different guard the session used in the admin is the same used for the frontpage and maybe I need to use different sessions to avoid this problem.

I even tried setting the redirect without $redirectTo and it's the same:

    return $this->authenticated($request, $this->guard()->user())
            ?: redirect()->intended('/admin/dashboard');

I'm using version 5.5.32


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us