mirror of
https://github.com/symfony/recipes.git
synced 2026-09-12 07:36:30 +03:00
[stimulus-bundle] Use defaultValue to change the value of hidden CSRF fields
This commit is contained in:
@@ -14,7 +14,7 @@ document.addEventListener('submit', function (event) {
|
||||
|
||||
if (!csrfCookie && nameCheck.test(csrfToken)) {
|
||||
csrfField.setAttribute('data-csrf-protection-cookie-value', csrfCookie = csrfToken);
|
||||
csrfField.value = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18))));
|
||||
csrfField.defaultValue = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18))));
|
||||
}
|
||||
|
||||
if (csrfCookie && tokenCheck.test(csrfToken)) {
|
||||
|
||||
Reference in New Issue
Block a user