summaryrefslogtreecommitdiffstats
path: root/pyload/database/User.py
diff options
context:
space:
mode:
authorGravatar ardi69 <armin@diedering.de> 2015-04-21 06:51:24 +0200
committerGravatar ardi69 <armin@diedering.de> 2015-04-21 06:51:24 +0200
commit2f8433b6a10505d29a1b63ea8bbd9b0bf3f7d9f6 (patch)
treeb82a8b5fc0a309f69733b0a004284f4ef45833d8 /pyload/database/User.py
parentadded check of classname == filename (diff)
parentMerge branch 'pr/n10_ardi69' into 0.4.10 (diff)
downloadpyload-2f8433b6a10505d29a1b63ea8bbd9b0bf3f7d9f6.tar.xz
Merge pull request #4 from vuolter/0.4.10
vuolter HEAD
Diffstat (limited to 'pyload/database/User.py')
-rw-r--r--pyload/database/User.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/pyload/database/User.py b/pyload/database/User.py
index e11961e32..2aedc3bba 100644
--- a/pyload/database/User.py
+++ b/pyload/database/User.py
@@ -30,7 +30,7 @@ class UserMethods(object):
@style.queue
def addUser(db, user, password):
- salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in range(0, 5)])
+ salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in xrange(0, 5)])
h = sha1(salt + password)
password = salt + h.hexdigest()
@@ -53,7 +53,7 @@ class UserMethods(object):
pw = r[2][5:]
h = sha1(salt + oldpw)
if h.hexdigest() == pw:
- salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in range(0, 5)])
+ salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in xrange(0, 5)])
h = sha1(salt + newpw)
password = salt + h.hexdigest()
@@ -76,24 +76,18 @@ class UserMethods(object):
@style.queue
def listUsers(db):
db.c.execute('SELECT name FROM users')
- users = []
- for row in db.c:
- users.append(row[0])
- return users
+ return [row[0] for row in db.c]
@style.queue
def getAllUserData(db):
db.c.execute("SELECT name, permission, role, template, email FROM users")
- user = {}
- for r in db.c:
- user[r[0]] = {"permission": r[1], "role": r[2], "template": r[3], "email": r[4]}
-
- return user
+ return {{"permission": r[1], "role": r[2], "template": r[3], "email": r[4]} for r in db.c}
@style.queue
def removeUser(db, user):
db.c.execute('DELETE FROM users WHERE name=?', (user,))
+
DatabaseBackend.registerSub(UserMethods)