MCPcopy
hub / github.com/pyload/pyload / addUser

Method addUser

module/database/UserDatabase.py:44–54  ·  view source on GitHub ↗
(db, user, password)

Source from the content-addressed store, hash-verified

42
43 @style.queue
44 def addUser(db, user, password):
45 salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for i in range(0, 5)])
46 h = sha1(salt + password)
47 password = salt + h.hexdigest()
48
49 c = db.c
50 c.execute('SELECT name FROM users WHERE name=?', (user, ))
51 if c.fetchone() is not None:
52 c.execute('UPDATE users SET password=? WHERE name=?', (password, user))
53 else:
54 c.execute('INSERT INTO users (name, password) VALUES (?, ?)', (user, password))
55
56
57 @style.queue

Callers 3

startMethod · 0.80
conf_basicMethod · 0.80
set_userMethod · 0.80

Calls 2

hexdigestMethod · 0.80
executeMethod · 0.80

Tested by

no test coverage detected