Replace weird username logic with the old logic.
authorGreg Price <price@mit.edu>
Thu, 29 Oct 2009 05:36:34 +0000 (01:36 -0400)
committerGreg Price <price@mit.edu>
Thu, 29 Oct 2009 05:36:34 +0000 (01:36 -0400)
remote_user_login() was just like the old getUser(), but different
in puzzling ways.

svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2700

code/view.py

index 1ecc827..a6fa610 100644 (file)
@@ -102,7 +102,7 @@ cherrypy.tools.jsonify = cherrypy.Tool('before_finalize', jsonify_tool_callback,
 
 def require_login():
     """If the user isn't logged in, raise 403 with an error."""
-    if cherrypy.request.login is False:
+    if not cherrypy.request.login:
         raise cherrypy.HTTPError(403,
             "You are not authorized to access that resource")
 
@@ -121,14 +121,13 @@ def remote_user_login():
     environ = cherrypy.request.wsgi_environ
     user = environ.get('REMOTE_USER')
     if user is None:
+        cherrypy.request.login = None
         return
-    else:
-        cherrypy.request.login = None # clear what cherrypy put there
 
     if environ.get('AUTH_TYPE') == 'Negotiate':
         # Convert the krb5 principal into a krb4 username
         if not user.endswith('@%s' % config.kerberos.realm):
-            cherrypy.request.login = False # failed to login
+            cherrypy.request.login = None
         else:
             cherrypy.request.login = user.split('@')[0].replace('/', '.')
     else: