lundi 5 mars 2018

Laravel redirect after successful login

I have created 2 extra Auth methods. When I use the regular Auth method a URL like /dashboard/pages/edit/1 will prompt for a login and after successful login the user is redirected to the initial URL instead of /dashboard/pages. But the other method like /secure/page will redirect the user to /secure after login is successful.

My LoginController has this:

public function redirectPath() {
    if (\Auth::user()->user_type_id <= 2) {
        return '/dashboard/pages';
    } else {
        if(Session::get('shopAuth')) {
            return '/shop';
        } else {
            return '/secure';
        }
    }
}

RedirectIfAuthenticated.php:

public function handle($request, Closure $next) {
    if ($this->auth->check()) {
        if (\Auth::user()->user_type_id <= 2) {
            return new RedirectResponse(url('/dashboard/pages'));
        } else {
            if(\Auth::user()->user_type_id == 3) {
                return new RedirectResponse(url('/shop'));
            } else {
                return new RedirectResponse(url('/secure'));
            }
        }

    }
    return $next($request);
}

The redirects all work, except the referer



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2FpX5gE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire