diff options
author | ankitjavalkar | 2016-01-22 17:49:23 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-01-22 17:49:23 +0530 |
commit | 45163b0a4de5b685c5fd57dea6abd51d4c343a35 (patch) | |
tree | 69bce77f8417479e16f8e824da3d972e3287c79a /yaksh/middleware/one_session_per_user.py | |
parent | 58bd6a8dbe0aa440ad8ec517fc85d388d02dc5e7 (diff) | |
download | online_test-45163b0a4de5b685c5fd57dea6abd51d4c343a35.tar.gz online_test-45163b0a4de5b685c5fd57dea6abd51d4c343a35.tar.bz2 online_test-45163b0a4de5b685c5fd57dea6abd51d4c343a35.zip |
Add docstring to middleware
Diffstat (limited to 'yaksh/middleware/one_session_per_user.py')
-rw-r--r-- | yaksh/middleware/one_session_per_user.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/yaksh/middleware/one_session_per_user.py b/yaksh/middleware/one_session_per_user.py index f382652..92e888d 100644 --- a/yaksh/middleware/one_session_per_user.py +++ b/yaksh/middleware/one_session_per_user.py @@ -5,9 +5,23 @@ 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, + 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) + """ def process_request(self, request): 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: |