-
Notifications
You must be signed in to change notification settings - Fork 877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSRF Token value is empty on form failure #337
Comments
Thanks for catching this @david-ridgeonnet I'll put a fix in asap |
Based on what we're saying looks to me like the simplest would be to add to the
|
Indeed, or you could amend this:
to this:
That way it returns the original value that the _token field was going to use. However while writing this I had a thought, what if it isn't just the If I have a form with a pre-filled value (e.g. just a standard text input) and submit the form. On the server, if I do extra validation and redirect back without specifying |
Since the issue appears to be directly involved with |
Yes but I'm also saying I think there is a further issue. If I have a form input like so:
Submit the page, and then in the function handling the request, simply do:
The current result means the form input will be rendered empty, without the This change has broken more than the |
I found the core issue:
needs to be
I have a test working replicating what youre saying above |
Sounds good to me � thanks for your time on this |
No problem - it actually all makes sense now - release coming in a few min |
Thanks - this has fixed. However the change in c0dc174 where you added the:
Will break when the csrfToken is not set (if you see the |
When the middleware
ConvertEmptyStringsToNull
is enabled and you submit a form, redirect back to the form with errors (without input), the_token
field no longer has a value. I have not tested redirecting back with input.This has caused a pain in the backside as essentially if they fail the the form and there's no "old" value for the
_token
field, it fills it with an empty value. This then causes any further attempts to fail due to aTokenMismatchException
.I thought at first my middleware wasn't working but can confirm this issue simply by checking the value that's passed from the
token
method to thehidden
method and the one that gets returned from thegetValueAttribute
for the_token
field. The value is correct before but it's null afterwards.A quick solution is to simply check at the top of
getValueAttribute
if the name is equal to the specified token field (e.g._token
).Thank you.
The text was updated successfully, but these errors were encountered: