Skip to content

Commit 6b8be73

Browse files
author
Nick Bragdon
authored
Merge pull request #4 from CMSgov/BB2-984_handle_bene_auth_rejection
[ BB2-984 ] Adding support for handling the rejection
2 parents 144e3c1 + cd2b06c commit 6b8be73

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

server/src/app/views.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ..entities.Settings import Settings
88
from ..utils.configUtil import getConfigSettings
99
from ..utils.bb2Util import generateAuthorizeUrl, getAccessToken, getBenefitData
10-
from ..utils.userUtil import getLoggedInUser
10+
from ..utils.userUtil import clearBB2Data, getLoggedInUser
1111
from ..shared.LoggerFactory import LoggerFactory
1212
import json
1313

@@ -16,6 +16,8 @@
1616
front-end to communicate with the server to retrieve data from Blue Button and Medicare.gov
1717
"""
1818

19+
BENE_DENIED_ACCESS = 'access_denied'
20+
1921
# initialize the logger object
2022
myLogger = LoggerFactory.get_logger(log_file=__name__,log_level='DEBUG')
2123
loggedInUser = getLoggedInUser()
@@ -56,7 +58,13 @@ def getCurrentAuthToken():
5658
def authorizationCallback():
5759
try:
5860
requestQuery = request.args
59-
61+
62+
if (requestQuery.get('error') == BENE_DENIED_ACCESS):
63+
# clear all saved claims data since the bene has denied access for the application
64+
clearBB2Data()
65+
myLogger.error('Beneficiary denied application access to their data')
66+
return redirect('http://localhost:3000')
67+
6068
if (requestQuery.get('code') == ''):
6169
myLogger.error('Response was missing access code!')
6270
if (DBsettings.pkce and requestQuery.get('state')):

server/src/utils/userUtil.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@
1111

1212
def getLoggedInUser():
1313
return DBusers[0]
14+
15+
def clearBB2Data():
16+
logged_in_user = getLoggedInUser()
17+
logged_in_user.update({'authToken': {
18+
'access_token' : '',
19+
'expires_in' : 0,
20+
'expires_at' : 0,
21+
'token_type' : '',
22+
'scope' : '',
23+
'refresh_token' : '',
24+
'patient' : ''
25+
}})
26+
logged_in_user.update({'eobData': ''})

0 commit comments

Comments
 (0)