I have a page that is supposed to be visible regardless of user log in. I've tried using $this->middleware('auth')->except('getStats')
but it didn't work. I tried to pass url in Handler.php
where it redirects unauthenticated users to login page, but it didn't work. Any suggestion would be appreciated as I've tried a lot of things but couldn't make it work.
Handler.php :
protected function unauthenticated($request, AuthenticationException $exception) {
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest(route('login'));
}
PlanningController.php (where I passed the except
):
public function __construct() {
parent::__construct();
$this->middleware('auth')->except('getStats');
}
RedirectIfAuthenticated.php
public function handle(Request $request, Closure $next, $guard = null)
{
// Teste si l'utilisateur est ok
if (Auth::guard($guard)->check()) {
// Redirige vers l'accueil
return redirect('/');
}
return $next($request);
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3rMBe9z
via IFTTT
Aucun commentaire:
Enregistrer un commentaire