Laravel extend the default web authentication guard

474 views Asked by At

I'm using the default laravel authentication but now I need to add the possibility to login directly to my app using a link with a specific token passed as GET param.

The Auth::viaRequest function seems to be a good way to approach this problem

Auth::viaRequest('custom-auth', function ($request) {
   if ($defaultGuardWorks) {
      return $userFromDefaultGuard;
   }
   
   if (!empty($request->get('auth-token')) {
     return userFromAuthToken($request->get('auth-token'));
   }

   return null;
});

The problem is, I don't know how to check the default laravel authentication guard before performing my own check

0

There are 0 answers