changeset 4194:9c80451df643

Setup user from stored session
author Florian Krupicka <florian.krupicka@googlemail.com>
date Sat, 28 Jun 2008 15:34:51 +0200
parents 1e954e802ed2
children 2d8a9f98382b
files MoinMoin/auth/__init__.py MoinMoin/wsgiapp.py
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/__init__.py	Fri Jun 27 18:38:29 2008 +0200
+++ b/MoinMoin/auth/__init__.py	Sat Jun 28 15:34:51 2008 +0200
@@ -301,3 +301,17 @@
         if not cont:
             break
     return userobj
+
+def setup_from_session(request, session):
+    userobj = None
+    if 'user.id' in session:
+        auth_userid = session['user.id']
+        auth_method = session['user.auth_method']
+        auth_attrs = session['user.auth_attribs']
+        if auth_method and auth_method in \
+                [ auth.name for auth in request.cfg.auth]:
+            userobj = user.User(request, id=auth_userid,
+                                auth_method=auth_method,
+                                auth_attribs=auth_attrs)
+    logging.debug("session started for user %r", userobj)
+    return userobj
--- a/MoinMoin/wsgiapp.py	Fri Jun 27 18:38:29 2008 +0200
+++ b/MoinMoin/wsgiapp.py	Sat Jun 28 15:34:51 2008 +0200
@@ -36,7 +36,10 @@
     request.session = request.cfg.session_service.get_session(request)
 
     # auth & user handling
-    userobj = None
+    # first try setting up from session
+    userobj = auth.setup_from_session(request, request.session)
+
+    # then handle login/logout forms 
     form = request.form
 
     if 'login' in form:
@@ -53,6 +56,7 @@
     else:
         userobj = auth.handle_request(request, userobj)
 
+    # check for setuid-handling of users
     userobj, olduser = check_setuid(request, userobj)
 
     if not userobj: