mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +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.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'sso.middleware.InactiveLogoutMiddleware',
|
||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
'pagination.middleware.PaginationMiddleware',
|
||||
'sso.middleware.IGBMiddleware',
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user