Author: damoxc
Revision: 5243
Log:
document the methods
Diff:
Modified: trunk/deluge/ui/web/auth.py
===================================================================
--- trunk/deluge/ui/web/auth.py 2009-05-07 18:02:08 UTC (rev 5242)
+++ trunk/deluge/ui/web/auth.py 2009-05-07 19:14:02 UTC (rev 5243)
@@ -47,6 +47,12 @@
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 @@
@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 @@
@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,8 +119,12 @@
@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()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---