Skip to content

Commit 839a799

Browse files
BLUEBUTTON-608 Robust userinfo logic in testclient (#702)
* Robust userinfo logic in testclient - prevents errors when patient doesn't have records.
1 parent 503f48d commit 839a799

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

apps/testclient/views.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ def callback(request):
4242
response['token_response'][k] = v
4343
else:
4444
response['token_response'][k] = ' '.join(v)
45+
userinfo_uri = request.session['userinfo_uri']
46+
try:
47+
userinfo = oas.get(userinfo_uri).json()
48+
except Exception:
49+
userinfo = {'patient': token.get('patient', None)}
50+
51+
request.session['patient'] = userinfo.get('patient', None)
4552

46-
userinfo = oas.get(request.session['userinfo_uri']).json()
4753
response['userinfo'] = userinfo
48-
request.session['patient'] = userinfo['patient']
4954

5055
response['oidc_discovery_uri'] = host + \
5156
reverse('openid-configuration')

0 commit comments

Comments
 (0)