Created
October 22, 2015 13:10
-
-
Save kelvan/3677f859960bb9e7205a to your computer and use it in GitHub Desktop.
Logout deactivated users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth import logout | |
from django.contrib import messages | |
from django.utils.translation import ugettext_lazy as _ | |
class LogoutDisabledUserMiddleware: | |
"""Logout user if it is deactivated | |
""" | |
def process_request(self, request): | |
if request.user.is_authenticated() and not request.user.is_active: | |
logout(request) | |
messages.add_message(request, messages.INFO, _('Your account was deactivated')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment