diff options
author | Damien Churchill <damoc@gmail.com> | 2009-05-07 19:14:02 +0000 |
---|---|---|
committer | Damien Churchill <damoc@gmail.com> | 2009-05-07 19:14:02 +0000 |
commit | 3276de91c345064bfda460166c27beb11330934f (patch) | |
tree | cee1a191387d5c6bccf9cc226e1f3f0afa113939 /deluge/ui/web/auth.py | |
parent | 7e291268bbba5188cf7dec71f3ecb70fe6ab99f4 (diff) | |
download | deluge-3276de91c345064bfda460166c27beb11330934f.tar.gz deluge-3276de91c345064bfda460166c27beb11330934f.tar.bz2 deluge-3276de91c345064bfda460166c27beb11330934f.zip |
document the methods
Diffstat (limited to 'deluge/ui/web/auth.py')
-rw-r--r-- | deluge/ui/web/auth.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/deluge/ui/web/auth.py b/deluge/ui/web/auth.py index e708c0c25..03b14c5cd 100644 --- a/deluge/ui/web/auth.py +++ b/deluge/ui/web/auth.py @@ -47,6 +47,12 @@ class Auth(JSONComponent): super(Auth, self).__init__("Auth") def _create_session(self, login='admin'): + """ + Creates a new session. + + :keyword login: str, the username of the user logging in, currently + only for future use. + """ m = hashlib.md5() m.update(login) m.update(str(time.time())) @@ -67,16 +73,32 @@ class Auth(JSONComponent): @export def change_password(self, new_password): + """ + Change the password. + + :param new_password: str, the password to change to + """ + log.debug("Changing password") + d = Deferred() salt = hashlib.sha1(str(random.getrandbits(40))).hexdigest() s = hashlib.sha1(salt) s.update(new_password) config = component.get("DelugeWeb").config config["pwd_salt"] = salt config["pwd_sha1"] = s.hexdigest() - log.debug("Changing password") + d.callback(True) + return d + @export def check_session(self, session_id): + """ + Check a session to see if it's still valid. + + :param session_id: str, the id for the session to remove + :returns: True if the session is valid, False if not. + :rtype: bool + """ d = Deferred() config = component.get("DelugeWeb").config d.callback(session_id in config["sessions"]) @@ -84,6 +106,11 @@ class Auth(JSONComponent): @export def delete_session(self, session_id): + """ + Removes a session. + + :param session_id: str, the id for the session to remove + """ d = Deferred() config = component.get("DelugeWeb").config del config["sessions"][session_id] @@ -92,7 +119,11 @@ class Auth(JSONComponent): @export def login(self, password): - """Method to allow the webui to authenticate + """ + Test a password to see if it's valid. + + :param password: str, the password to test + :returns: a session id or False """ config = component.get("DelugeWeb").config d = Deferred() |