mardi 27 février 2018

redirect in Auth/LoginController

I am trying to redirect the user from the auth/login to a uri that I have stored in a session var. I am trying to override the redierectTo method found in Auth/LoginController (or at least I think that's how its done), but it keeps on redirecting to the /home page.

I have tried using the constructor like

protected $redirectTo = '';

public function __construct()
  {
    $this->middleware('guest')->except('logout');
    $this->redirectTo = Session::get('uri');
}

but it redirects to the /home page

I've tried to override the redirectTo method like so:

 protected function redirectTo()
  {

     return Session::get('uri');
  }

also redirects to the /home page

I've tried overriding the redirectPath method of the redirectPath in the RedirectIfAuthenticated file:

protected function redirectPath()
  {

     return Session::get('uri');
  }

Still redirects to the /home page

I've tried to change the redirect('/home') to redirect(Session::get('uri')) in the RedirectIfAuthenticated middleware

 public function handle($request, Closure $next, $guard = null)
  {
    if (Auth::guard($guard)->check()) {
        return redirect(Session::get('uri'));
    }

    return $next($request);
  }

still redirects to the /home page

I'm stumped any help greatly appreciated. Thanx in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire