Search code examples
djangodjango-socialauth

Django Social Auth and inactive users


For my site I am using Django auth app and django-social-auth (https://github.com/omab/django-social-auth) apps and both are working fine.

The problem arises when due to business logic I mark a social login user as inactive. Now when this users tries to login he is redirected back to login page automatically.

Can I somehow notify the user that his account is marked as inactive when user is redirected to login page?


Solution

  • Can you show us some code?

    Anyway, I think you could solve this with Django Messages app. You'd override your login() or authenticate() functions and in the section which tests whether the user is_active, you'd make some arbitrary action; in this case you would set a message explaining the error, that the system couldn't log the user in because the user is inactive. And in your login view, you'd check whether there are any messages set and in such a case you'd simply render them.