Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Tidy up code for remembering the IDP #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions app/main/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,15 @@ def match_idp_email(idp, email_address):


def dept_from_idp_name(idp_name):
idp = [idp['name'] for idp in idp_profiles if idp_name == idp['idp_name']]
if idp:
return ' or '.join(idp)
return None
depts = None
for profile in idp_profiles:
if idp_name == profile['idp_name']:
if depts is None:
depts = []
depts.append(profile['name'])

if depts:
return ' or '.join(depts)


def idp_for_dept(dept):
Expand Down Expand Up @@ -149,8 +154,8 @@ def authentication_request():

elif request.cookies.get('gateway_idp'):
session['suggested_idp'] = request.cookies.get('gateway_idp')
department = dept_from_idp_name(session['suggested_idp'])
session['department_name'] = department
session['department_name'] = dept_from_idp_name(
session['suggested_idp'])
return redirect(url_for('.confirm_dept'))

return redirect(url_for('.request_email_address'))
Expand Down