4

On our service there's admins and other users. I'm using the basic Laravel Auth package for handling registrations, logins etc.

What would be the best way to implement a feature, where an admin user could "fake login" as a regular user, without knowing the actual user's password?

2 Answers 2

12

This should work:

Auth::loginUsingId($userId, true);
3

There is a function in laravel Auth::loginUsingId():

if(Auth::loginUsingId($userId))
{
    return redirect('/dashboard');
}

by which user can login by using its id in user table only. In this there is no need to pass email, password etc

Not the answer you're looking for? Browse other questions tagged or ask your own question.