How to disable intermediate signout page in Django allauth

前端 未结 3 985
太阳男子
太阳男子 2021-02-18 19:24

How to disable the intermediate signout page from django allauth. When the user clicks on the signout link on my site I want him to logout right away, I want to remove this inte

3条回答
  •  感动是毒
    2021-02-18 19:44

    Updated for December 2018.

    Using a GET request is probably a bad idea due to browsers prefetching urls from the URL bar. Chrome (as of right now) is pretty bad for this; it'll send a GET request to pages it think you'll hit enter on when typing in your URL bar.

    Plus, people can add a link such as and you'll be logged out. That's not a security risk since it's logging you out, but it is certainly annoying for your users.

    Instead, you should consider using a POST request using a form with CSRF. Django Allauth already comes with this. Here's the

    from the intermediate signout page:

    
      {% csrf_token %}
      {% if redirect_field_value %}
        
      {% endif %}
      
    
    

    In my case, I just added this to the site header and made the submit

提交回复
热议问题