File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,11 +5,21 @@ import Settings from '../entities/Settings';
55import db from '../utils/db' ;
66import { getAccessToken , generateAuthorizeUrl } from '../utils/bb2' ;
77import { getBenefitData } from './Data' ;
8- import { getLoggedInUser } from 'src/utils/user' ;
8+ import { clearBB2Data , getLoggedInUser } from 'src/utils/user' ;
9+
10+ const BENE_DENIED_ACCESS = 'access_denied' ;
911
1012
1113export async function authorizationCallback ( req : Request , res : Response ) {
1214 try {
15+
16+ if ( req . quey . error === BENE_DENIED_ACCESS ) {
17+ const loggedInUser = getLoggedInUser ( db ) ;
18+ // clear all saved claims data since the bene has denied access for the application
19+ clearBB2Data ( loggedInUser ) ;
20+ loggedInUser . errors . push ( BENE_DENIED_ACCESS ) ;
21+ throw new Error ( 'Beneficiary denied application access to their data' ) ;
22+ }
1323
1424 if ( ! req . query . code ) {
1525 throw new Error ( 'Response was missing access code' ) ;
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ export interface UserInfo {
1616export interface User {
1717 authToken ?: AuthorizationToken ,
1818 userInfo : UserInfo ,
19- eobData ?: any
19+ eobData ?: any ,
20+ errors : string [ ]
2021}
2122export interface DB {
2223 patients : object ,
@@ -51,7 +52,8 @@ const db: DB = {
5152 userName : 'jdoe29999' ,
5253 pcp : 'Dr. Hibbert' ,
5354 primaryFacility : 'Springfield General Hospital'
54- }
55+ } ,
56+ errors : [ ]
5557 } ] ,
5658 codeChallenges : { } ,
5759 codeChallenge : {
Original file line number Diff line number Diff line change 1- import { DB } from "./db" ;
1+ import { DB , User } from "./db" ;
22
33/* DEVELOPER NOTES:
44* Here we are literally just grabbing the first user
@@ -9,4 +9,9 @@ import { DB } from "./db";
99*/
1010export function getLoggedInUser ( db : DB ) {
1111 return db . users [ 0 ] ;
12+ }
13+
14+ export function clearBB2Data ( user : User ) {
15+ user . authToken = undefined ;
16+ user . eobData = undefined ;
1217}
You can’t perform that action at this time.
0 commit comments