From 1b17a82d62c4a6d8f430e4d13716916fe3722291 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Wed, 7 Jan 2015 16:31:04 -0200 Subject: [PATCH] Add maintenance script to discover user from sessionid --- scripts/user_from_session.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 scripts/user_from_session.py diff --git a/scripts/user_from_session.py b/scripts/user_from_session.py new file mode 100644 index 0000000..853aeb7 --- /dev/null +++ b/scripts/user_from_session.py @@ -0,0 +1,10 @@ +from django.contrib.sessions.models import Session +from django.contrib.auth.models import User + + +def user_from_session(session_key): + session = Session.objects.get(session_key=session_key) + uid = session.get_decoded().get('_auth_user_id') + user = User.objects.get(pk=uid) + print user.username, user.get_full_name(), user.email + return user