dimanche 14 octobre 2018

Laravel redirect user if user is login

I have an application that has two authentications i.e user and admin.

I want to redirect the user to a specific page if they are already login. Like if the user is already logged in then the URL http://example.com/log should take the user to URL http://example.com/dashboard.

Similarly, if an admin is already logged in then, URL http://example.com/admin/login should redirect them to URL http://example.com/admin/dashboard.

The problem is I can change the handle method to redirect to only one page in RedirectIfAuthenticated page. Any idea on how to check if request is from admin or user in that page.

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

        return $next($request);
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire