diff --git a/api/workAllocation/caseWorkerUserDataCacheService.ts b/api/workAllocation/caseWorkerUserDataCacheService.ts index 7cdd3df82d..9a8e7edc3f 100644 --- a/api/workAllocation/caseWorkerUserDataCacheService.ts +++ b/api/workAllocation/caseWorkerUserDataCacheService.ts @@ -56,11 +56,7 @@ export async function fetchNewUserData(): Promise { refreshRoles = true; await getAuthTokens(); // add the tokens to the request headers - const caseworkerHeaders = { - 'content-type': 'application/json', - 'serviceAuthorization': `Bearer ${initialServiceAuthToken}`, - 'authorization': `Bearer ${initialAuthToken}` - }; + const caseworkerHeaders = getRequestHeaders(); const jurisdictions = getConfigValue(STAFF_SUPPORTED_JURISDICTIONS); cachedUsers = []; const getUsersPath: string = prepareGetUsersUrl(baseCaseWorkerRefUrl, jurisdictions); @@ -114,9 +110,7 @@ export async function fetchRoleAssignmentsForNewUsers(cachedUserData: StaffUserD const jurisdictions = getStaffSupportedJurisdictionsList(); const payload = prepareRoleApiRequest(jurisdictions); const roleAssignmentHeaders = { - 'content-type': 'application/json', - 'serviceAuthorization': `Bearer ${initialServiceAuthToken}`, - 'authorization': `Bearer ${initialAuthToken}`, + ...getRequestHeaders(), pageNumber: 0, size: 10000 }; @@ -177,6 +171,14 @@ export function timestampExists(): boolean { return !!timestamp; } +export function getRequestHeaders(): any { + return { + 'content-type': 'application/json', + 'serviceAuthorization': `Bearer ${initialServiceAuthToken}`, + 'authorization': `Bearer ${initialAuthToken}`, + }; +} + // get the request information from config - similarly in node-lib export const getRequestBody = (): string => { const userName = getConfigValue(SYSTEM_USER_NAME);