Commit 5cf3acfd authored by Jonathan Schaeffer's avatar Jonathan Schaeffer

Bugfix authentication error 500

ça venait du fait qu'on cherchait un réseau par sa date de début ET de
fin.
Hors, Z3 a changé de date de fin => on ne le trouvait plus en base.
En fait, il faut utiliser seulement la date de début.
parent d6bc8627
......@@ -123,14 +123,20 @@ def register_privileges(login, fdsn_refs):
for ref in fdsn_refs:
ref['login'] = login
ref['expires_at'] = datetime.datetime.now()+datetime.timedelta(days=1)
cur.execute("""
select network_id from networks where start_year=%(startyear)s and end_year=%(endyear)s and network=%(networkcode)s;
""", ref)
logging.info(ref)
sql_request = "select network_id from networks where start_year=%(startyear)s and network=%(networkcode)s"
try:
cur.execute(sql_request, ref)
if cur.rowcount != 1:
logging.info(cur.mogrify(sql_request, ref))
logging.error("No network found for %s", ref)
ref['networkid'] = cur.fetchone()[0]
logging.info("Inserting tupple in %s.eida_temp_users: %s"%(application.config['PRIVILEGEDBNAME'], ref))
logging.info("Inserting tupple in %s.eida_temp_users: %s", application.config['PRIVILEGEDBNAME'], ref)
cur.execute("""
insert into eida_temp_users (network_id, network, start_year, end_year, name, expires_at) values (%(networkid)s, %(networkcode)s, %(startyear)s, %(endyear)s, %(login)s, %(expires_at)s);
""", ref)
except psycopg2.Error as e:
logging.error(e.pgerror)
conn.commit()
conn.close()
......
Markdown is supported
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