changeset 4638:7bc4d1571f8f

suid: simplify and fix, bigger selection box
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 08 Mar 2009 18:20:25 +0100
parents ff5be6bb7a49
children 49c9b9ba737f
files MoinMoin/auth/__init__.py MoinMoin/userprefs/suid.py
diffstat 2 files changed, 6 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/__init__.py	Sun Mar 08 13:33:04 2009 +0100
+++ b/MoinMoin/auth/__init__.py	Sun Mar 08 18:20:25 2009 +0100
@@ -433,7 +433,7 @@
     @return: (new_user, user) or (user, None)
     """
     old_user = None
-    if 'setuid' in request.session and userobj.isSuperUser():
+    if 'setuid' in request.session and userobj and userobj.isSuperUser():
         old_user = userobj
         uid = request.session['setuid']
         userobj = user.User(request, uid, auth_method='setuid')
--- a/MoinMoin/userprefs/suid.py	Sun Mar 08 13:33:04 2009 +0100
+++ b/MoinMoin/userprefs/suid.py	Sun Mar 08 18:20:25 2009 +0100
@@ -26,10 +26,7 @@
         self.name = 'suid'
 
     def allowed(self):
-        return (UserPrefBase.allowed(self) and
-                self.request.user.isSuperUser() or
-                (not self.request._setuid_real_user is None and
-                 (self.request._setuid_real_user.isSuperUser())))
+        return UserPrefBase.allowed(self) and self.request.user.isSuperUser()
 
     def handle_form(self):
         _ = self._
@@ -59,27 +56,21 @@
     def _user_select(self):
         options = []
         users = user.getUserList(self.request)
-        realuid = None
-        if hasattr(self.request, '_setuid_real_user') and self.request._setuid_real_user:
-            realuid = self.request._setuid_real_user.id
-        else:
-            realuid = self.request.user.id
+        current_uid = self.request.user.id
         for uid in users:
-            if uid != realuid:
+            if uid != current_uid:
                 name = user.User(self.request, id=uid).name
                 options.append((uid, name))
         options.sort(lambda x, y: cmp(x[1].lower(), y[1].lower()))
 
-        size = min(5, len(options))
-        current_user = self.request.user.id
-
         if not options:
             _ = self._
             self._only = True
             return _("You are the only user.")
 
         self._only = False
-        return util.web.makeSelection('selected_user', options, current_user, size=size)
+        size = min(10, len(options))
+        return util.web.makeSelection('selected_user', options, current_uid, size=size)
 
     def create_form(self):
         """ Create the complete HTML form code. """