Extracting logic to methods to improve readability

Guys I was reading the code and I thought about some changes in `setup_csrf_protection` method.

I don't know the indentation and stye of code that you guys use, so tell me if I made something wrong.

This PR includes 2 changes:
* Fixed a typo error
* Removed the nested `if` from `setup_csrf_protection`
* Refactored `setup_csrf_protection` method to keep it smaller

:v: Peace on Earth :v: