lundi 9 novembre 2020

Laravel Auth in middleware

I have some problems with authentication on my middleware file. I'm logging on which page is client last seen, like so:

public function handle(Request $request, Closure $next)
    {
        Activity::create(['user_id' => Auth::id(), 'ip_id' => SecureAgent::getIP(), 'action' => $request->method(), 'page' => $request->path()]);
        

        return $next($request);
    }

File in Karnel is added in $middleware;

The problem is that Auth::id() is not working, only NULL. I have logged in with passport, set my token and redirect to profile page, everything is working fine except this middleware.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire