Skip to content

Commit da31685

Browse files
authored
Add a remark to submit-eventListener (#1418)
1 parent c017382 commit da31685

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const nameCheck = /^[-_a-zA-Z0-9]{4,22}$/;
22
const tokenCheck = /^[-_/+a-zA-Z0-9]{24,}$/;
33

44
// Generate and double-submit a CSRF token in a form field and a cookie, as defined by Symfony's SameOriginCsrfTokenManager
5+
// Use `form.requestSubmit()` to ensure that the submit event is triggered. Using `form.submit()` will not trigger the event
6+
// and thus this event-listener will not be executed.
57
document.addEventListener('submit', function (event) {
68
generateCsrfToken(event.target);
79
}, true);

0 commit comments

Comments
 (0)