Skip to content

Commit

Permalink
BLUEBUTTON-608 Robust userinfo logic in testclient (#702)
Browse files Browse the repository at this point in the history
* Robust userinfo logic in testclient

- prevents errors when patient doesn't have records.
  • Loading branch information
whytheplatypus authored Feb 6, 2019
1 parent 503f48d commit 839a799
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/testclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ def callback(request):
response['token_response'][k] = v
else:
response['token_response'][k] = ' '.join(v)
userinfo_uri = request.session['userinfo_uri']
try:
userinfo = oas.get(userinfo_uri).json()
except Exception:
userinfo = {'patient': token.get('patient', None)}

request.session['patient'] = userinfo.get('patient', None)

userinfo = oas.get(request.session['userinfo_uri']).json()
response['userinfo'] = userinfo
request.session['patient'] = userinfo['patient']

response['oidc_discovery_uri'] = host + \
reverse('openid-configuration')
Expand Down

0 comments on commit 839a799

Please sign in to comment.