refactor(actions): centralize wave-2 post/csrf guards
This commit is contained in:
@@ -78,7 +78,8 @@ function actionRequireCsrf(
|
||||
string $flashKeyPrefix = 'csrf_expired',
|
||||
bool $jsonAware = false,
|
||||
string $jsonError = 'csrf',
|
||||
bool $flashOnFailure = true
|
||||
bool $flashOnFailure = true,
|
||||
bool $redirectOnFailure = true
|
||||
): bool {
|
||||
if (Session::checkCsrfToken()) {
|
||||
return true;
|
||||
@@ -96,7 +97,9 @@ function actionRequireCsrf(
|
||||
flashFormErrors($errorBag, $flashScope ?? $redirect, $flashKeyPrefix);
|
||||
}
|
||||
|
||||
Router::redirect($redirect);
|
||||
if ($redirectOnFailure) {
|
||||
Router::redirect($redirect);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user