diff --git a/back/src/config/bootstrap/appConfig.ts b/back/src/config/bootstrap/appConfig.ts index e227d50acd..98c49a7ba8 100644 --- a/back/src/config/bootstrap/appConfig.ts +++ b/back/src/config/bootstrap/appConfig.ts @@ -324,7 +324,7 @@ export class AppConfig { ? "https://fake-pro-connect.url" : undefined, ), - scope: "openid given_name usual_name email custom", + scope: "openid given_name usual_name email custom siret", }; } diff --git a/back/src/domains/core/authentication/inclusion-connect/adapters/oauth-gateway/HttpOAuthGateway.ts b/back/src/domains/core/authentication/inclusion-connect/adapters/oauth-gateway/HttpOAuthGateway.ts index 084ae76e38..067757462b 100644 --- a/back/src/domains/core/authentication/inclusion-connect/adapters/oauth-gateway/HttpOAuthGateway.ts +++ b/back/src/domains/core/authentication/inclusion-connect/adapters/oauth-gateway/HttpOAuthGateway.ts @@ -152,6 +152,7 @@ export class HttpOAuthGateway implements OAuthGateway { lastName: oAuthIdTokenPayload.usual_name, email: oAuthIdTokenPayload.email, structure_pe: oAuthIdTokenPayload.custom.structureTravail, + siret: oAuthIdTokenPayload.siret, }, }; } diff --git a/back/src/domains/core/authentication/inclusion-connect/entities/OAuthIdTokenPayload.ts b/back/src/domains/core/authentication/inclusion-connect/entities/OAuthIdTokenPayload.ts index e56702e915..d138dfa1df 100644 --- a/back/src/domains/core/authentication/inclusion-connect/entities/OAuthIdTokenPayload.ts +++ b/back/src/domains/core/authentication/inclusion-connect/entities/OAuthIdTokenPayload.ts @@ -1,4 +1,4 @@ -import { Email, ExternalId, emailSchema } from "shared"; +import { Email, ExternalId, SiretDto, emailSchema, siretSchema } from "shared"; import { z } from "zod"; type ProviderTokenPayloadBase = { @@ -15,6 +15,7 @@ export type IcOAuthIdTokenPayload = ProviderTokenPayloadBase & { export type ProConnectOAuthIdTokenPayload = ProviderTokenPayloadBase & { usual_name: string; + siret: SiretDto; custom: { structureTravail?: string; }; @@ -39,4 +40,5 @@ export const proConnectAuthTokenPayloadSchema: z.Schema localDeviceRepository.delete("federatedIdentityWithUser")), + tap(() => localDeviceRepository.delete("connectedUserSiret")), tap(() => localDeviceRepository.delete("partialConventionInUrl")), map(() => authSlice.actions.federatedIdentityInDeviceDeletionSucceeded()), ); diff --git a/front/src/core-logic/ports/DeviceRepository.ts b/front/src/core-logic/ports/DeviceRepository.ts index 88e241c941..3bc4e3d847 100644 --- a/front/src/core-logic/ports/DeviceRepository.ts +++ b/front/src/core-logic/ports/DeviceRepository.ts @@ -13,7 +13,8 @@ export type LocalStoragePair = | GenericPair<"partialConventionInUrl", Partial> | GenericPair<"adminToken", string> | GenericPair<"federatedIdentityWithUser", FederatedIdentityWithUser> - | GenericPair<"searchResultExternal", SearchResultDto>; + | GenericPair<"searchResultExternal", SearchResultDto> + | GenericPair<"connectedUserSiret", string>; export type SessionStoragePair = | GenericPair<"acquisitionParams", WithAcquisition> diff --git a/shared/src/inclusionConnect/inclusionConnect.dto.ts b/shared/src/inclusionConnect/inclusionConnect.dto.ts index def560534f..b7d439b3c6 100644 --- a/shared/src/inclusionConnect/inclusionConnect.dto.ts +++ b/shared/src/inclusionConnect/inclusionConnect.dto.ts @@ -28,6 +28,7 @@ export type WithSourcePage = { export type AuthenticatedUserQueryParams = { token: InclusionConnectJwt; idToken: string; + siret?: string; // remove optional when inclusion connect is removed } & Pick; type InclusionConnectConventionManageAllowedRole =