XF 2.0 Disable CSRF protection on login & register

Jean-Baptiste

Well-known member
Hello,

I would like to disable CSRF protection for login & registration actions.

Any ideas on how to do this ?

Best regards
 
Add the following function to the controller (ideally extend with an add-on to preserve the override):

PHP:
public function checkCsrfIfNeeded($action, ParameterBag $params)
{
    if (strtolower($action) == 'the-action')
    {
        return;
    }

    parent::checkCsrfIfNeeded($action, $params);
}

If you want to disable it for the entire controller, just override with a blank function.

What's the use case? It's generally not a good idea to disable it unless you really have to.
 
Back
Top Bottom