I need to redirect to logout if user has role 'teacher'. I tried to do that with middleware but I dont know what is the problem here. It says
This page isn’t working 127.0.0.1 redirected you too many times.
, sometimes Auth:user() is null for no reason I guess.
Middleware:
public function handle($request, Closure $next)
{
if (Auth::user()->role == User::ROLE_TEACHER) {
return redirect()->route('logout');
}
return $next($request);
}
Kernel:
protected $routeMiddleware = [
.....
'noTeacher' => \App\Http\Middleware\RedirectIfTeacher::class,
];
HomeController:
$this->middleware('noTeacher', ['only' => 'index']);
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2WYoUGR
via IFTTT
Aucun commentaire:
Enregistrer un commentaire