summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyload/Setup.py2
-rw-r--r--pyload/database/UserDatabase.py18
2 files changed, 12 insertions, 8 deletions
diff --git a/pyload/Setup.py b/pyload/Setup.py
index 2ecd6ebe6..c1af46295 100644
--- a/pyload/Setup.py
+++ b/pyload/Setup.py
@@ -303,7 +303,7 @@ class Setup():
print ""
username = self.ask(_("Username"), "")
if username:
- db.removeUser(username)
+ db.removeUserByName(username)
noaction = False
elif action == "4":
db.syncSave()
diff --git a/pyload/database/UserDatabase.py b/pyload/database/UserDatabase.py
index 3dd06c912..8d8381a40 100644
--- a/pyload/database/UserDatabase.py
+++ b/pyload/database/UserDatabase.py
@@ -19,17 +19,18 @@ from hashlib import sha1
from string import letters, digits
from random import choice
-alphnum = letters+digits
+alphnum = letters + digits
from pyload.Api import UserData
from DatabaseBackend import DatabaseMethods, queue, async
+
def random_salt():
- return "".join(choice(alphnum) for x in range(0,5))
+ return "".join(choice(alphnum) for x in range(0, 5))
-class UserMethods(DatabaseMethods):
+class UserMethods(DatabaseMethods):
@queue
def addUser(self, user, password):
salt = random_salt()
@@ -116,10 +117,13 @@ class UserMethods(DatabaseMethods):
self.c.execute("UPDATE users SET role=? WHERE name=?", (role, user))
# TODO update methods
-
@async
- def removeUser(self, uid=None):
- # deletes user and all associated accounts
- self.c.execute('DELETE FROM users WHERE user=?', (uid, ))
+ def removeUserByName(self, name):
+ self.c.execute("SELECT uid from users WHERE name=?", (name,))
+ uid = self.c.fetchone()
+ if uid:
+ # deletes user and all associated accounts
+ self.c.execute('DELETE FROM users WHERE user=?', (uid[0], ))
+
UserMethods.register()