Skip to content

Commit f1b0398

Browse files
committed
✨ suggest ministere des armees for intraf.gouv.fr emails
1 parent 1a92a48 commit f1b0398

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/controllers/organization.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ import {
4848
extractRejectionReason,
4949
} from "../services/moderation";
5050

51+
const SIRET_SUGGESTIONS = [
52+
{
53+
domains: ["intradef.gouv.fr"],
54+
siret: "11009001600053",
55+
},
56+
];
57+
5158
export const getJoinOrganizationController = async (
5259
req: Request,
5360
res: Response,
@@ -60,7 +67,7 @@ export const getJoinOrganizationController = async (
6067
do_not_propose_suggestions: optionalBooleanSchema(),
6168
});
6269

63-
const { notification, siret_hint, do_not_propose_suggestions } =
70+
let { notification, siret_hint, do_not_propose_suggestions } =
6471
await schema.parseAsync(req.query);
6572

6673
const { id: user_id, email } = getUserFromAuthenticatedSession(req);
@@ -74,13 +81,23 @@ export const getJoinOrganizationController = async (
7481
return res.redirect("/users/organization-suggestions");
7582
}
7683

84+
const emailDomain = getEmailDomain(email);
85+
86+
if (!siret_hint) {
87+
for (const SIRET_SUGGESTION of SIRET_SUGGESTIONS) {
88+
if (SIRET_SUGGESTION.domains.includes(emailDomain)) {
89+
siret_hint = SIRET_SUGGESTION.siret;
90+
break;
91+
}
92+
}
93+
}
94+
7795
return res.render("user/join-organization", {
7896
pageTitle: "Rejoindre une organisation",
7997
notifications: await getNotificationsFromRequest(req),
8098
csrfToken: csrfToken(req),
8199
siretHint: siret_hint,
82-
useGendarmerieSearchHint:
83-
getEmailDomain(email) === "gendarmerie.interieur.gouv.fr",
100+
useGendarmerieSearchHint: emailDomain === "gendarmerie.interieur.gouv.fr",
84101
});
85102
} catch (error) {
86103
next(error);

0 commit comments

Comments
 (0)