Hello,
I created a website where users can subscribe an account. My authentication system is based on roles and permissions. Currently, as an administrator, if I want to access a user account (in moderation ...), I click on a link from my administration panel and I can access the account through my userlevel who is a admin.
I would like to know if there is another method to access a user account while maintaining my connection active to the admin panel. Indeed, I would like to know if Laravel can manage simultaneous mutiples autentifications without losing the main administrator connection ? (I do no want to reconnect me to the admin panel after each access to the page of a member).
Spark does something similar, you can see it here: Episode 6
I don't know how spark achieve it, but I've done something similar in the past using sessions. You have a page that logs yourself as the other user and then save in the session some reference to the admin account. The normal site will treat you like the user you are impersonating, while a custom page can read the extra session information and restore your admin account.
In the user table, create à field : token and populate with a random string every time the administrator logged in.
Then in the admin panel when you click on a "view profile" link for a specific user, the administrator token is set in session.
After that, i use Auth::loginUsingId($id); to connect me to a user account.
To return to the admin panel without reintroducing credentials, i placed a link in the user dropdown menu (back to admin) witch check if the session is set, retrieve the token and check if a user in the database has this token. After, i process simply by Auth::loginUsingId($admin_id); again.