Skip to content

Commit 18dd79b

Browse files
Resolve throttle middleware alias in 2FA preview pipeline.
Pipeline: :through() cannot resolve middleware aliases directly, so resolve them through the router before executing the 2FA challenge middleware stack. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e211c70 commit 18dd79b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/Http/Middleware/PreviewOr2FAThrottle.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Auth\AuthenticationException;
77
use Illuminate\Http\Request;
88
use Illuminate\Routing\Pipeline;
9+
use Illuminate\Routing\Router;
910
use Symfony\Component\HttpFoundation\Response;
1011

1112
class PreviewOr2FAThrottle
@@ -25,12 +26,14 @@ public function handle(Request $request, Closure $next): Response
2526
}
2627

2728
// Otherwise execute the middleware you would have attached.
29+
$middleware = app(Router::class)->resolveMiddleware([
30+
TwoFactorChallenged::class,
31+
'throttle:5,1',
32+
]);
33+
2834
return app(Pipeline::class)
2935
->send($request)
30-
->through([
31-
TwoFactorChallenged::class,
32-
'throttle:5,1',
33-
])
36+
->through($middleware)
3437
->then(fn ($request) => $next($request));
3538
}
3639
}

0 commit comments

Comments
 (0)