Commit 33173342 authored by Martin Mareš's avatar Martin Mareš
Browse files

Apparantly, CAS changed how multiple mail addresses are passed

They could have told...
parent 7ee5fdd8
......@@ -1352,8 +1352,13 @@ def cas_login():
def parse_cas_emails(raw_email):
if raw_email[0] == '{' and raw_email[-1] == '}':
if isinstance(raw_email, list):
return raw_email
elif raw_email == "":
return []
elif raw_email[0] == '{' and raw_email[-1] == '}':
# Strange CAS encoding of multiple e-mail addresses
# Apparently, newer versions of CAS pass a list instead
return raw_email[1:-1].split(',')
else:
return [raw_email]
......@@ -1363,7 +1368,7 @@ def primary_cas_email(raw_email):
emails = parse_cas_emails(raw_email)
if not emails:
return None
uk = [e for e in emails if e.endswith('.cuni.cz')]
uk = [e for e in emails if e.endswith('.cuni.cz') and not e.endswith('@o365.cuni.cz')]
if uk:
return uk[0]
else:
......
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