From 81a761ae7e8bb95567c9ad47a20bfcf1b3073593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Mon, 9 Nov 2015 10:56:18 +0100 Subject: Bugfix: SAML login method did not return correct field for the e-mail. --- server/user_session.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/user_session.py b/server/user_session.py index 79dc93d..19c29c6 100644 --- a/server/user_session.py +++ b/server/user_session.py @@ -146,13 +146,15 @@ class UserSession(object): try: cur = conn.cursor() try: - cur.execute('update codeq_user set name = coalesce(%s, name), email = coalesce(%s, email), saml_data = %s, last_login = %s where username = %s and password is null returning id, gui_lang, date_joined, robot_address, gui_layout', (name, email, psycopg2.extras.Json(saml_data), str(now), eduPersonPrincipalName)) + cur.execute('update codeq_user set name = coalesce(%s, name), email = coalesce(%s, email), saml_data = %s, last_login = %s where username = %s and password is null returning id, gui_lang, date_joined, robot_address, gui_layout, email', (name, email, psycopg2.extras.Json(saml_data), str(now), eduPersonPrincipalName)) row = cur.fetchone() if row: self.uid = row[0] self.username = eduPersonPrincipalName self.settings = {'gui_lang': row[1], 'robot_address': row[3], 'gui_layout': row[4]} date_joined = row[2] + if email is None: + email = row[5] else: # the account does not exist yet, either create one or upgrade an existing one while True: # a trick loop, so we are able to exit the code block where ever we want @@ -189,7 +191,7 @@ class UserSession(object): finally: cur.close() conn.commit() - return name, eduPersonPrincipalName, date_joined, now + return name, email, date_joined, now finally: db.return_connection(conn) -- cgit v1.2.1