summaryrefslogtreecommitdiffstats
path: root/deluge/ui/web/auth.py
diff options
context:
space:
mode:
authorDamien Churchill <damoc@gmail.com>2009-08-20 00:31:31 +0000
committerDamien Churchill <damoc@gmail.com>2009-08-20 00:31:31 +0000
commit1a635e8860edb0f8988e38d4b5d4d3548dfb274b (patch)
treed0b9e2226464bef6ef75a259933b7c2a0a4818a6 /deluge/ui/web/auth.py
parent7d0ccb8847acf8e755274eed3d290b78e35956de (diff)
downloaddeluge-1a635e8860edb0f8988e38d4b5d4d3548dfb274b.tar.gz
deluge-1a635e8860edb0f8988e38d4b5d4d3548dfb274b.tar.bz2
deluge-1a635e8860edb0f8988e38d4b5d4d3548dfb274b.zip
only return deferreds for those methods that require it
Diffstat (limited to 'deluge/ui/web/auth.py')
-rw-r--r--deluge/ui/web/auth.py21
1 files changed, 6 insertions, 15 deletions
diff --git a/deluge/ui/web/auth.py b/deluge/ui/web/auth.py
index b0cede765..d700ecb66 100644
--- a/deluge/ui/web/auth.py
+++ b/deluge/ui/web/auth.py
@@ -254,11 +254,8 @@ class Auth(JSONComponent):
:param new_password: the password to change to
:type new_password: string
"""
- d = Deferred()
-
if not self.check_password(old_password):
- d.callback(False)
- return d
+ return False
log.debug("Changing password")
salt = hashlib.sha1(str(random.getrandbits(40))).hexdigest()
@@ -267,8 +264,7 @@ class Auth(JSONComponent):
config = component.get("DelugeWeb").config
config["pwd_salt"] = salt
config["pwd_sha1"] = s.hexdigest()
- d.callback(True)
- return d
+ return True
@export(AUTH_LEVEL_NONE)
def check_session(self, session_id=None):
@@ -278,9 +274,7 @@ class Auth(JSONComponent):
:returns: True if the session is valid, False if not.
:rtype: booleon
"""
- d = Deferred()
- d.callback(__request__.session_id is not None)
- return d
+ return __request__.session_id is not None
@export
def delete_session(self):
@@ -293,8 +287,7 @@ class Auth(JSONComponent):
d = Deferred()
config = component.get("DelugeWeb").config
del config["sessions"][__request__.session_id]
- d.callback(True)
- return d
+ return True
@export(AUTH_LEVEL_NONE)
def login(self, password):
@@ -307,9 +300,7 @@ class Auth(JSONComponent):
:rtype: string or False
"""
- d = Deferred()
if self.check_password(password):
- d.callback(self._create_session(__request__))
+ return self._create_session(__request__)
else:
- d.callback(False)
- return d
+ return False