Answer the question
In order to leave comments, you need to log in
Log in from admin to user and go back, how?
Good evening. There is an admin panel and a user account. From the admin, I would like to make a transition to the user panel using Auth::loginUsingId(1). Everything seems to be clear with this, but how to return back to the admin panel, in fact, we have lost the admin authorization at the same time. You can use cookies, but it's not very secure. What would be the best implementation option?
Answer the question
In order to leave comments, you need to log in
I write in session.
After all, I also hope to log in through the session (cookies should not be touched)
Why would you do Auth::loginUsingId(1)? Why is it impossible to work in the admin panel with the same user as in the office? Add a group field for the user and don't use crutches with authorization.
Let's understand why you need it ... obviously, to see some documents of this user (as if on his behalf), but why not just give the admin the opportunity to view the user's documents?
It is clear that then you need to be able to separate one user from another and their documents, respectively.
You can solve this if you rebuild the routes a little. Instead site.ru/posts
of taking a user from auth
, it site.ru/users/{id}/posts
's very easy to restrict the user's access to your own posts, and give the admin access to other people's posts using the h-rbac authorization module. Moreover, it is no less easy to give managers access only to some specific users or groups of users and their documents, and, for example, only documents of a certain type. I think this option is much more flexible.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question