Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2641 - récupérer le siret de l'utilisateur Pro Connecté #2864

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion back/src/config/bootstrap/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class HttpOAuthGateway implements OAuthGateway {
lastName: oAuthIdTokenPayload.usual_name,
email: oAuthIdTokenPayload.email,
structure_pe: oAuthIdTokenPayload.custom.structureTravail,
siret: oAuthIdTokenPayload.siret,
},
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Email, ExternalId, emailSchema } from "shared";
import { Email, ExternalId, SiretDto, emailSchema, siretSchema } from "shared";
import { z } from "zod";

type ProviderTokenPayloadBase = {
Expand All @@ -15,6 +15,7 @@ export type IcOAuthIdTokenPayload = ProviderTokenPayloadBase & {

export type ProConnectOAuthIdTokenPayload = ProviderTokenPayloadBase & {
usual_name: string;
siret: SiretDto;
custom: {
structureTravail?: string;
};
Expand All @@ -39,4 +40,5 @@ export const proConnectAuthTokenPayloadSchema: z.Schema<ProConnectOAuthIdTokenPa
custom: z.object({
structureTravail: z.string().optional(),
}),
siret: siretSchema,
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type GetAccessTokenPayload = {
lastName: string;
email: Email;
structure_pe?: string;
siret?: string; // remove optional when inclusion connect is removed
};

export type GetAccessTokenResult = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export class AuthenticateWithInclusionCode extends TransactionalUseCase<
firstName: newOrUpdatedAuthenticatedUser.firstName,
lastName: newOrUpdatedAuthenticatedUser.lastName,
email: newOrUpdatedAuthenticatedUser.email,
siret: payload.siret,
idToken,
})}`;
}
Expand Down
6 changes: 6 additions & 0 deletions front/src/app/routes/InclusionConnectedPrivateRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useAppSelector } from "src/app/hooks/reduxHooks";
import { FrontAdminRouteTab } from "src/app/pages/admin/AdminTabs";
import { routes } from "src/app/routes/routes";
import { loginIllustration } from "src/assets/img/illustrations";
import { outOfReduxDependencies } from "src/config/dependencies";
import { authSelectors } from "src/core-logic/domain/auth/auth.selectors";
import { authSlice } from "src/core-logic/domain/auth/auth.slice";
import { featureFlagSelectors } from "src/core-logic/domain/featureFlags/featureFlags.selector";
Expand Down Expand Up @@ -133,6 +134,7 @@ export const InclusionConnectedPrivateRoute = ({
firstName = "",
lastName = "",
idToken = "",
siret = "",
} = route.params;

if (token) {
Expand All @@ -149,6 +151,10 @@ export const InclusionConnectedPrivateRoute = ({
feedbackTopic: "auth-global",
}),
);
outOfReduxDependencies.localDeviceRepository.set(
"connectedUserSiret",
siret,
);
const { token: _, ...routeParams } = route.params;
routes[route.name](routeParams as any).replace();
}
Expand Down
1 change: 1 addition & 0 deletions front/src/app/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type AcquisitionParams = Partial<{
type AcquisitionParamsKeys = keyof typeof acquisitionParams;

const inclusionConnectedParams = createInclusionConnectedParams({
siret: param.query.optional.string,
page: param.query.optional.string,
token: param.query.optional.string,
firstName: param.query.optional.string,
Expand Down
1 change: 1 addition & 0 deletions front/src/core-logic/domain/auth/auth.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const deleteFederatedIdentityFromDevice: AuthEpic = (
action$.pipe(
filter(authSlice.actions.federatedIdentityDeletionTriggered.match),
tap(() => localDeviceRepository.delete("federatedIdentityWithUser")),
tap(() => localDeviceRepository.delete("connectedUserSiret")),
tap(() => localDeviceRepository.delete("partialConventionInUrl")),
map(() => authSlice.actions.federatedIdentityInDeviceDeletionSucceeded()),
);
Expand Down
3 changes: 2 additions & 1 deletion front/src/core-logic/ports/DeviceRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export type LocalStoragePair =
| GenericPair<"partialConventionInUrl", Partial<ConventionParamsInUrl>>
| GenericPair<"adminToken", string>
| GenericPair<"federatedIdentityWithUser", FederatedIdentityWithUser>
| GenericPair<"searchResultExternal", SearchResultDto>;
| GenericPair<"searchResultExternal", SearchResultDto>
| GenericPair<"connectedUserSiret", string>;

export type SessionStoragePair =
| GenericPair<"acquisitionParams", WithAcquisition>
Expand Down
1 change: 1 addition & 0 deletions shared/src/inclusionConnect/inclusionConnect.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type WithSourcePage = {
export type AuthenticatedUserQueryParams = {
token: InclusionConnectJwt;
idToken: string;
siret?: string; // remove optional when inclusion connect is removed
} & Pick<User, "email" | "firstName" | "lastName">;

type InclusionConnectConventionManageAllowedRole =
Expand Down
Loading