Prepare code for CSRF protection
Refactor code to use CSRF protection