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?


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.


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.

链接地址: http://www.djcxy.com/p/33726.html

上一篇: 带有Apache虚拟主机的中间件或子域的子域?

下一篇: Django Social Auth和非活动用户