_csrf_token and custom code

21 views
Skip to first unread message

Johan Pieterse

unread,
Mar 13, 2023, 1:54:16 AMMar 13
to AtoM Users
Good day all

I have previously developed custom code in 2.4.
Now when trying to upgraded the code to 2.7 I get _csrf_token issues.

I know this is technical and cannot find in other posts the answer but how do I add _csrf_token to my custom code? I did some hacks but would like to do it "right"

Thanks
Johan

Johan Pieterse

unread,
Mar 13, 2023, 2:00:14 AMMar 13
to AtoM Users
I did disable it in settings for now

Dan Gillean

unread,
Mar 13, 2023, 9:23:10 AMMar 13
to ica-ato...@googlegroups.com
Hi Johan, 

I found this PR, which might help? I am not a developer, but looking at the file changes, I would suggest you have 2 options you can try: 
  • The first is to use the method implemented in these changes to see if adding that line will make your forms validate, or
  • The second is to use the previous workaround this PR was removing, which is to disable CSRF validation on a specific form using $this->form->disableCSRFProtection();
See: 

--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/ecd2df4d-d5af-4f11-9925-6b07933a5987n%40googlegroups.com.

José Raddaoui

unread,
Mar 13, 2023, 9:57:37 AMMar 13
to AtoM Users
Hi Johan,

If you are customizing templates, you may need to add the CSRF hidden field in their forms. See an example of the changes needed in a template form after enabling CSRF protection:


If you are modifying actions, I'd suggest you check the latest version of them in the default implementation, specially those commits and PR Dan linked above.

Best,
Radda.

Johan Pieterse

unread,
Mar 16, 2023, 3:26:01 PMMar 16
to José Raddaoui, ica-ato...@googlegroups.com
Thanks all will look tomorrow. 

Sent from my HONOR phone
You received this message because you are subscribed to a topic in the Google Groups "AtoM Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ica-atom-users/QOKndMFmJb0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/595d1bc4-4d73-4a60-9f96-624f820aa765n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages