diff options
author | Damien Churchill <damoc@gmail.com> | 2009-09-23 18:16:08 +0000 |
---|---|---|
committer | Damien Churchill <damoc@gmail.com> | 2009-09-23 18:16:08 +0000 |
commit | ce449e7b3bc5eb8da1eb4b7890d02fc015dcb7d2 (patch) | |
tree | 39c9d8711115ff93b666153337ab62fd0c8c1cf3 /deluge/ui/web/auth.py | |
parent | a23812f880f197452ed1dc05b5efa53a5b6a2df0 (diff) | |
download | deluge-ce449e7b3bc5eb8da1eb4b7890d02fc015dcb7d2.tar.gz deluge-ce449e7b3bc5eb8da1eb4b7890d02fc015dcb7d2.tar.bz2 deluge-ce449e7b3bc5eb8da1eb4b7890d02fc015dcb7d2.zip |
fix bug when upgrading old passwords on new logins
Diffstat (limited to 'deluge/ui/web/auth.py')
-rw-r--r-- | deluge/ui/web/auth.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/deluge/ui/web/auth.py b/deluge/ui/web/auth.py index 13339d03d..b32e5477d 100644 --- a/deluge/ui/web/auth.py +++ b/deluge/ui/web/auth.py @@ -160,7 +160,7 @@ class Auth(JSONComponent): 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 @@ class Auth(JSONComponent): # 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 @@ class Auth(JSONComponent): 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 @@ class Auth(JSONComponent): 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): """ |