diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-15 19:24:55 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-15 19:24:55 +0200 |
commit | 551611b088cfae503305adc380f0e6d9cd2538f6 (patch) | |
tree | f2bbef690eeae0d06c31277d5060aebefb2b94a6 /pyload/database/UserDatabase.py | |
parent | also update file size when loading progress (diff) | |
download | pyload-551611b088cfae503305adc380f0e6d9cd2538f6.tar.xz |
fixed user deletion
Diffstat (limited to 'pyload/database/UserDatabase.py')
-rw-r--r-- | pyload/database/UserDatabase.py | 18 |
1 files changed, 11 insertions, 7 deletions
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() |