1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 12:54:05 +00:00

feat(UniversalRoutes): Stop overwriting the (maybe) customized onFail method and just call it in case of an exception

This commit is contained in:
Bemigho 2021-06-22 08:39:49 +02:00
parent 1a5300ab4f
commit 8fb3eb0abd

View file

@ -23,12 +23,14 @@ class UniversalRoutes implements Feature
public function bootstrap(Tenancy $tenancy): void
{
foreach (static::$identificationMiddlewares as $middleware) {
$middleware::$onFail = function ($exception, $request, $next) {
$originalOnFail = $middleware::$onFail;
$middleware::$onFail = function ($exception, $request, $next) use ($originalOnFail) {
if (static::routeHasMiddleware($request->route(), static::$middlewareGroup)) {
return $next($request);
}
throw $exception;
return $originalOnFail($exception, $request, $next);
};
}
}