Commit 493b4571 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Merge branch 'dblock' into 'master'

Store the password for future reuse.

See merge request !4
parents fc21860a fc477b86
Pipeline #47770 passed with stage
in 42 seconds
......@@ -123,11 +123,11 @@ def get_login_password(tokendict):
application.logger.debug(cur.mogrify("select user_index,login from users where email=%s and expires_at between now()+'1 hour' and now()+'26 hours'", (tokendict['mail'],)))
if cur.rowcount != 0:
(uid, login) = cur.fetchone()
application.logger.debug("Found a temporary account corresponding to %s", tokendict['mail'])
cur.execute("select ws_hash from credentials where user_index=%s", (uid,))
application.logger.debug("Found a temporary account corresponding to %s: %s", tokendict['mail'], uid)
cur.execute("select password_hash from credentials where user_index=%s", (uid,))
if cur.rowcount != 0:
password = cur.fetchone()[0]
application.logger.debug("Found correspondig password also")
application.logger.debug("Found correspondig password also: %s", password)
# If not found, compute a random login and password
if not login or not password:
application.logger.debug("No existing user found. Create a new one")
......@@ -141,9 +141,9 @@ def get_login_password(tokendict):
{'login': login, 'givenName': tokendict['givenName'], 'sn': tokendict['sn'], 'mail': tokendict['mail'], 'expires_at': expiration_time }
INSERT INTO credentials VALUES (CURRVAL('users_user_index_seq'), NULL, %(wsshash)s, %(expires_at)s);
INSERT INTO credentials (user_index, password_hash, ws_hash, expires_at) VALUES (CURRVAL('users_user_index_seq'), %(password)s, %(wsshash)s, %(expires_at)s);
{'wsshash': wsshash(login, password), 'expires_at': expiration_time }
{'wsshash': wsshash(login, password), 'expires_at': expiration_time, 'password': password }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment