Question

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?

Was it helpful?

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.

OTHER TIPS

There is an option for this:

SOCIAL_AUTH_INACTIVE_USER_URL = '/inactive-user/'

From manual:

Inactive users can be redirected to this URL when trying to authenticate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top