Skip to content

Instantly share code, notes, and snippets.

View dedayoa's full-sized avatar

Dayo Ayeni dedayoa

View GitHub Profile
@dedayoa
dedayoa / middleware.py
Created April 3, 2017 13:31
Django middleware to automatically log user out after X minutes
import arrow #you can use datetime here
from django.contrib import auth
from django.utils import timezone
from django.conf import settings # where I have set FORCE_LOGOUT_IN to 5
class AutoForceLogoutMiddleware(object):
SESSION_KEY = 'auto-force-logout'
def __init__(self, get_response=None):