fix the tests failure
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m16s
API CI/CD / Build frontend assets (push) Successful in 2m15s
API CI/CD / Security audit (push) Successful in 32s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m16s
API CI/CD / Build frontend assets (push) Successful in 2m15s
API CI/CD / Security audit (push) Successful in 32s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -13,13 +13,27 @@ class MultiAuth
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$sanctumUser = Auth::guard('sanctum')->user();
|
||||
try {
|
||||
$sanctumUser = Auth::guard('sanctum')->user();
|
||||
} catch (\InvalidArgumentException) {
|
||||
$sanctumUser = null;
|
||||
}
|
||||
|
||||
if ($sanctumUser) {
|
||||
Auth::setUser($sanctumUser);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
try {
|
||||
if ($apiUser = Auth::guard('api')->user()) {
|
||||
Auth::setUser($apiUser);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
}
|
||||
|
||||
$token = $request->bearerToken();
|
||||
if ($token) {
|
||||
try {
|
||||
@@ -30,7 +44,6 @@ class MultiAuth
|
||||
return $next($request);
|
||||
}
|
||||
} catch (JWTException $e) {
|
||||
// fall through to unauthorized response
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user