Skip to content

Commit fe4629e

Browse files
committed
Allow configs to be added to frontend form and auth end routes
1 parent f9fce30 commit fe4629e

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

config/routes.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,30 @@
5353

5454
'middleware' => 'web',
5555

56+
/*
57+
|--------------------------------------------------------------------------
58+
| Auth Route Middleware
59+
|--------------------------------------------------------------------------
60+
|
61+
| Additional middleware applied to the frontend auth routes (login,
62+
| register, password reset, etc). Useful for rate limiting, e.g.
63+
| 'throttle:4,1' to allow 4 attempts per minute.
64+
|
65+
*/
66+
67+
'auth_middleware' => [],
68+
69+
/*
70+
|--------------------------------------------------------------------------
71+
| Forms Route Middleware
72+
|--------------------------------------------------------------------------
73+
|
74+
| Additional middleware applied to the frontend form submission route.
75+
| Useful for rate limiting, e.g. 'throttle:30,1' to allow 30 submissions
76+
| per minute.
77+
|
78+
*/
79+
80+
'forms_middleware' => [],
81+
5682
];

routes/web.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434

3535
Route::name('statamic.')->group(function () {
3636
Route::group(['prefix' => config('statamic.routes.action')], function () {
37-
Route::post('forms/{form}', [FormController::class, 'submit'])->middleware([HandlePrecognitiveRequests::class])->name('forms.submit');
37+
Route::post('forms/{form}', [FormController::class, 'submit'])->middleware(array_merge([HandlePrecognitiveRequests::class], (array) config('statamic.routes.forms_middleware', [])))->name('forms.submit');
3838

3939
Route::get('protect/password', [PasswordProtectController::class, 'show'])->name('protect.password.show')->middleware([HandleInertiaRequests::class]);
4040
Route::post('protect/password', [PasswordProtectController::class, 'store'])->name('protect.password.store');
4141

42-
Route::group(['prefix' => 'auth', 'middleware' => [AuthGuard::class]], function () {
42+
Route::group(['prefix' => 'auth', 'middleware' => array_merge([AuthGuard::class], (array) config('statamic.routes.auth_middleware', []))], function () {
4343
Route::get('logout', [LoginController::class, 'logout'])->name('logout');
4444

4545
Route::group(['middleware' => [HandlePrecognitiveRequests::class]], function () {

0 commit comments

Comments
 (0)