Welcome Guest, Not a member yet? Register   Sign In
I have a problem with ajax and csrf - The action you requested is not allowed.
#5

(This post was last modified: 08-10-2022, 04:41 PM by PHS.)

Hi, I'm going to take advantage of this thread because today I was all day trying to figure out why my form wasn't being submitted, until I discovered that it was the Security.php > $regenerate setting, which was active. I updated my project with the latest version of CI, in the old project $regenerate was disabled.

Well, I would like to ask the CI4 experts what is the implication of leaving $regenerate disabled, is there any threat?

Second question, usually in my forms I use javascript to present some special effect to the user when submitting the form, usually I use something like:

Code:
document.getElementById('myForm').addEventListener('submit', function (event) {
event.preventDefault();
/*
implementation code
*/
event.currentTarget.submit();
}



If the javascript file submits the form via the method e.currentTarget.submit() and csrf regenerate is enabled the form is not submitted, because as for each request the regenerate changes to a new token. In this case, how could I submit the form, using the same method with javascript and with csrf regenerate enabled?

Thanks!
Reply


Messages In This Thread
RE: I have a problem with ajax and csrf - The action you requested is not allowed. - by PHS - 08-10-2022, 04:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB