Correct way to route users to different panels based on their role?
I have role based access, and I have several different panels in my app. I have app, admin, and client panels. When I log in wiht the roles that should have app or admin panel access, everything works fine. When I log in with a role that should only have client panel access, I immediately get the auth error, "These credentials do not match our records" on the login screen. As soon as I change the role of the user, I'm able to login with the same credentials.
I have this method in my User model, which seems to be getting hit when the login happens, and if I dd the
$panel
, it's always attempting to go to the app panel.
Where would be the appropriate place to basically redirect to the client panel based on their role. I would think that would be in a middleware somewhere, but maybe I'm missing something? Should I just add it to this method? I would think this canAccessPanel
method would be one of the last to be called after the middleware, and I'm not sure why it's failing with that error message, because the credentials are correct.0 Replies