404labfr / laravel-impersonate

Laravel Impersonate is a plugin that allows you to authenticate as your users.
https://marceau.casals.fr
1.99k stars 201 forks source link

Impersonate doesn't work because don't open a user session #73

Open fferraro87 opened 5 years ago

fferraro87 commented 5 years ago

Hi, i'm using impersonate 1.2 on my laravel 5.6 installation. I'm going to admin area and on every user i've put a button "login as user" and i call impersonate function on my HomeController :

    public function impersonate($user_id){
        if ($user_id!= ''){
        $user = User::find($user_id);
        Auth::user()->impersonate($user);
        return redirect()->route('myPlan.history');
        }
        return redirect()->back();
    }

but when i click on that i cannot open route myPlan.history impersonated as other user. But if i login with another simple user and then go back to admin area and click again on "login as user" every works fine, so i think that function doesn't create a user session. How can i fix? Thanks

MarceauKa commented 5 years ago

Do you use the web guard? Can you show your User model?