mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:14:04 +00:00
feat(UniversalRoutes): Stop overwriting the (maybe) customized onFail… (#679)
* feat(UniversalRoutes): Stop overwriting the (maybe) customized onFail method and just call it in case of an exception * throw correct exception when `$originalOnFail()` is null * Update DomainTest.php * convert test to pest and renamed * Update tests/DomainTest.php Co-authored-by: Samuel Štancl <samuel@archte.ch> Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com> Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
parent
f9c9d8615f
commit
233a1222bf
2 changed files with 19 additions and 1 deletions
|
|
@ -23,11 +23,17 @@ 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);
|
||||
}
|
||||
|
||||
if ($originalOnFail) {
|
||||
return $originalOnFail($exception, $request, $next);
|
||||
}
|
||||
|
||||
throw $exception;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue