diff --git a/DeploymentSteps.md b/DeploymentSteps.md index 85066df7f..be1fc4f66 100644 --- a/DeploymentSteps.md +++ b/DeploymentSteps.md @@ -13,6 +13,9 @@ Don't delete old sections - just leave them towards the bottom of the file, and ## Next (pending changes for the next coming release) 1. Admin must be deployed before the portal to include the Role changes needed for setting client types (sas-UID2-1782-approved-types-to-admin) + +## 0.7.5 + 2. Keycloak needs to update realm display name to UID2 Portal ## 0.6.0 diff --git a/src/api/routers/usersRouter.ts b/src/api/routers/usersRouter.ts index fa9ccd992..98ee61651 100644 --- a/src/api/routers/usersRouter.ts +++ b/src/api/routers/usersRouter.ts @@ -57,19 +57,15 @@ export function createUsersRouter() { }); usersRouter.get('/current/participant', async (req: UserRequest, res) => { - try { - const currentParticipant = await Participant.query().findOne({ id: req.user!.participantId }); - const sites = await getSiteList(); - const currentSite = sites.find((x) => x.id === currentParticipant?.siteId); - const allParticipantTypes = await ParticipantType.query(); - const result = { - ...currentParticipant, - types: mapClientTypeToParticipantType(currentSite?.clientTypes || [], allParticipantTypes), - }; - return res.status(200).json(result); - } catch (error: unknown) { - console.log(error); - } + const currentParticipant = await Participant.query().findOne({ id: req.user!.participantId }); + const sites = await getSiteList(); + const currentSite = sites.find((x) => x.id === currentParticipant?.siteId); + const allParticipantTypes = await ParticipantType.query(); + const result = { + ...currentParticipant, + types: mapClientTypeToParticipantType(currentSite?.clientTypes || [], allParticipantTypes), + }; + return res.status(200).json(result); }); usersRouter.use('/:userId', enrichWithUserFromParams); diff --git a/src/api/services/adminServiceClient.ts b/src/api/services/adminServiceClient.ts index 56d7bd9a6..c4df8445e 100644 --- a/src/api/services/adminServiceClient.ts +++ b/src/api/services/adminServiceClient.ts @@ -5,7 +5,13 @@ import { z } from 'zod'; import { ParticipantApprovalPartial } from '../entities/Participant'; import { SSP_ADMIN_SERVICE_BASE_URL, SSP_ADMIN_SERVICE_CLIENT_KEY } from '../envars'; import { getLoggers } from '../helpers/loggingHelpers'; -import { ClientType, KeyPairDTO, SharingListResponse, SiteDTO } from './adminServiceHelpers'; +import { + ClientType, + KeyPairDTO, + mapClientTypesToAdminEnums, + SharingListResponse, + SiteDTO, +} from './adminServiceHelpers'; const adminServiceClient = axios.create({ baseURL: SSP_ADMIN_SERVICE_BASE_URL, @@ -22,29 +28,6 @@ const DEFAULT_SHARING_SETTINGS: Pick -): string[] => { - return participantApprovalPartial.types.map((type) => { - let adminEnum = 'UNKNOWN'; - switch (type.id) { - case 1: - adminEnum = 'DSP'; - break; - case 2: - adminEnum = 'ADVERTISER'; - break; - case 3: - adminEnum = 'DATA_PROVIDER'; - break; - case 4: - adminEnum = 'PUBLISHER'; - break; - } - return adminEnum; - }); -}; - export const getSharingList = async ( siteId: number, traceId: string @@ -131,7 +114,7 @@ export const addKeyPair = async ( if (error instanceof AxiosError) { errorMessage = error.response?.data.message as string; } - errorLogger.error(`Get ACLs failed: ${errorMessage}`, traceId); + errorLogger.error(`Add keypair failed: ${errorMessage}`, traceId); throw error; } }; diff --git a/src/api/services/adminServiceHelpers.ts b/src/api/services/adminServiceHelpers.ts index 10719ca41..deb9d6481 100644 --- a/src/api/services/adminServiceHelpers.ts +++ b/src/api/services/adminServiceHelpers.ts @@ -1,3 +1,6 @@ +import { z } from 'zod'; + +import { ParticipantApprovalPartial } from '../entities/Participant'; import { ParticipantTypeData, ParticipantTypeDTO } from '../entities/ParticipantType'; type ClientRole = 'ID_READER' | 'GENERATOR' | 'MAPPER' | 'OPTOUT' | 'SHARER'; @@ -54,3 +57,26 @@ export function GetRecommendedRoles(roles: ParticipantTypeDTO[]) { const recommendedRolesWithDuplicates = roles.flatMap((r) => AllowedSiteRoles[r.typeName]); return [...new Set(recommendedRolesWithDuplicates)]; } + +export const mapClientTypesToAdminEnums = ( + participantApprovalPartial: z.infer +): string[] => { + return participantApprovalPartial.types.map((type) => { + let adminEnum = 'UNKNOWN'; + switch (type.id) { + case 1: + adminEnum = 'DSP'; + break; + case 2: + adminEnum = 'ADVERTISER'; + break; + case 3: + adminEnum = 'DATA_PROVIDER'; + break; + case 4: + adminEnum = 'PUBLISHER'; + break; + } + return adminEnum; + }); +};