mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Added middleware to kick out users set as not active
This commit is contained in:
@@ -66,6 +66,7 @@ MIDDLEWARE_CLASSES = (
|
|||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
'sso.middleware.InactiveLogoutMiddleware',
|
||||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||||
'pagination.middleware.PaginationMiddleware',
|
'pagination.middleware.PaginationMiddleware',
|
||||||
'sso.middleware.IGBMiddleware',
|
'sso.middleware.IGBMiddleware',
|
||||||
|
|||||||
@@ -1,4 +1,15 @@
|
|||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
|
from django.contrib.auth import logout
|
||||||
|
|
||||||
|
class InactiveLogoutMiddleware(object):
|
||||||
|
"""
|
||||||
|
Detect inactive and logged in users and log them out
|
||||||
|
"""
|
||||||
|
|
||||||
|
def process_request(self, request):
|
||||||
|
if request.user.is_authenticated() and not request.user.is_active:
|
||||||
|
logout(request)
|
||||||
|
|
||||||
|
|
||||||
class IGBMiddleware(object):
|
class IGBMiddleware(object):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user