changeset 2499:b5a711a9ec09

Fix generation of auth tokens in xmlrpc code.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 22 Jul 2007 05:09:45 +0200
parents 3b3b76b2225c
children 7203f7cc4201
files MoinMoin/xmlrpc/__init__.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/xmlrpc/__init__.py	Sun Jul 22 05:09:26 2007 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Sun Jul 22 05:09:45 2007 +0200
@@ -622,11 +622,16 @@
             except caching.CacheError:
                 pass
 
-    def _generate_auth_token(self):
+    def _generate_auth_token(self, usr):
+        """Generate a token that can be used to authorize next requests
+
+        @type usr: MoinMoin.user
+
+        """
         token = random_string(32, 'abcdefghijklmnopqrstuvwxyz0123456789')
         centry = caching.CacheEntry(self.request, 'xmlrpc-session', token,
                                     scope='farm', use_pickle=True)
-        centry.update((time.time() + 15*3600, u.id))
+        centry.update((time.time() + 15*3600, usr.id))
         return token
 
     def xmlrpc_getAuthToken(self, username, password, *args):
@@ -641,7 +646,7 @@
                                      password=password, login=True)
 
         if u and u.valid:
-            return _generate_auth_token()
+            return self._generate_auth_token(u)
         else:
             return ""
 
@@ -663,7 +668,7 @@
         u = self.request.handle_jid_auth(jid)
 
         if u and u.valid:
-            return _generate_auth_token()
+            return self._generate_auth_token(u)
         else:
             return ""