From 97b657edc2a323f832c81f0e34ce5761bd21f7e9 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 24 May 2018 12:07:39 +0530 Subject: Pep8 changes --- yaksh/middleware/one_session_per_user.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'yaksh/middleware/one_session_per_user.py') diff --git a/yaksh/middleware/one_session_per_user.py b/yaksh/middleware/one_session_per_user.py index 92e888d..1ed1786 100644 --- a/yaksh/middleware/one_session_per_user.py +++ b/yaksh/middleware/one_session_per_user.py @@ -7,21 +7,27 @@ from yaksh.models import ConcurrentUser class OneSessionPerUserMiddleware(object): """ Middleware to handle multiple logins with same credentials - - Creates a Database entry to record the current user and active session key - - Checks if the current user has already been logged in. If True, the new session - key is stored with respect to the user and the old session key is deleted, + - Creates a Database entry to record the current user and active + session key + - Checks if the current user has already been logged in. If True, the + new session key is stored with respect to the user and the old + session key is deleted, effectively terminating the older session for the same user. - - The concurrentuser attribute of the User model refers to the ConcurrentUser - model object and not the concurrent_user field due to behaviour described - in the Documentation - Link: https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#extending-the-existing-user-model) + - The concurrentuser attribute of the User model refers to the + ConcurrentUser + model object and not the concurrent_user field due to behaviour + described in the Documentation + Link: https://docs.djangoproject.com/en/1.5/topics/auth/customizing/ + #extending-the-existing-user-model """ def process_request(self, request): + """ + # Documentation: + # https://docs.djangoproject.com/en/1.5/topics/auth/customizing/ + #extending-the-existing-user-model + """ if isinstance(request.user, User): current_key = request.session.session_key - # - # Documentation: - # https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#extending-the-existing-user-model if hasattr(request.user, 'concurrentuser'): active_key = request.user.concurrentuser.session_key if active_key != current_key: @@ -32,4 +38,4 @@ class OneSessionPerUserMiddleware(object): ConcurrentUser.objects.create( concurrent_user=request.user, session_key=current_key, - ) \ No newline at end of file + ) -- cgit