Author: damoxc

Revision: 5768

Log:
        fix bug when upgrading old passwords on new logins

Diff:
Modified: trunk/deluge/ui/web/auth.py
===================================================================
--- trunk/deluge/ui/web/auth.py 2009-09-21 05:39:43 UTC (rev 5767)
+++ trunk/deluge/ui/web/auth.py 2009-09-23 18:16:08 UTC (rev 5768)
@@ -160,7 +160,7 @@
             if m.hexdigest() == config['pwd_md5']:
                 # We want to move the password over to sha1 and remove
                 # the old passwords from the config file.
-                self.change_password(password)
+                self._change_password(password)
                 del config.config["pwd_md5"]
                 
                 # Remove the older password if there is now.
@@ -181,7 +181,7 @@
                 
                 # We want to move the password over to sha1 and remove
                 # the old passwords from the config file.
-                self.change_password(password)
+                self._change_password(password)
                 del config.config["old_pwd_salt"]
                 del config.config["old_pwd_md5"]
                 
@@ -252,20 +252,15 @@
         if auth_level < level:
             raise AuthError("Not authenticated")
     
-    @export
-    def change_password(self, old_password, new_password):
+    def _change_password(self, new_password):
         """
-        Change the password.
+        Change the password. This is to allow the UI to change/reset a
+        password.
         
-        :param old_password: the current password
-        :type old_password: string
         :param new_password: the password to change to
         :type new_password: string
         """
-        if not self.check_password(old_password):
-            return False
-        
-        log.debug("Changing password")        
+        log.debug("Changing password")
         salt = hashlib.sha1(str(random.getrandbits(40))).hexdigest()
         s = hashlib.sha1(salt)
         s.update(new_password)
@@ -274,6 +269,20 @@
         config["pwd_sha1"] = s.hexdigest()
         return True
     
+    @export
+    def change_password(self, old_password, new_password):
+        """
+        Change the password.
+        
+        :param old_password: the current password
+        :type old_password: string
+        :param new_password: the password to change to
+        :type new_password: string
+        """
+        if not self.check_password(old_password):
+            return False
+        return self._change_password(new_password)
+    
     @export(AUTH_LEVEL_NONE)
     def check_session(self, session_id=None):
         """



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to