404labfr / laravel-impersonate

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

Redirect url feature #172

Open cardei opened 1 year ago

cardei commented 1 year ago

It is a small improvement that will permit to pass a redirection url when it is needed. To pass a url different from the used in config file:

Use Session::put('imp_back_url', 'CUSTOM_URL');

before impersonate

Example of use before impersonate:

if($request->back_url){
      $request->session()->put('imp_back_url', $request->back_url);
}

return redirect(route('impersonate', $request->user_id));

This session imp_back_url will be cleared when user leave impersonate.

With this small improvement it is posible to pass custom redirection url when needed or use default from config if it's not passed trough session.

It is working fine and solved my needs. I hope it's make sense.

cardei commented 1 year ago

It will be nice to have this in the main repository 😉

SkyspotEmil commented 8 months ago

This is a nice feature that i have wanted for some time :) Instead of doing it directly in the ImpersonateController I think it would be prettier to do it in the ImpersonateManager

@MarceauKa what is needed for this to be merged into master?