Skip to content

Instantly share code, notes, and snippets.

@jvadillo
Created October 21, 2018 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvadillo/df60e945d19c62d2cd887c839cc06dfc to your computer and use it in GitHub Desktop.
Save jvadillo/df60e945d19c62d2cd887c839cc06dfc to your computer and use it in GitHub Desktop.
Redirect after login depending on user role
//Edit the following function (RedirectIfAuthenticated.php):
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
//return redirect('/inicio');
if(Auth::user()->hasAnyRole('admin')){
return redirect()->route('datos');
}
else if (Auth::user()->hasAnyRole('club','equipo')){
return redirect()->route('inicio');
}
}
return $next($request);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment