@@ -48,6 +48,13 @@ import {
48
48
extractRejectionReason ,
49
49
} from "../services/moderation" ;
50
50
51
+ const SIRET_SUGGESTIONS = [
52
+ {
53
+ domains : [ "intradef.gouv.fr" ] ,
54
+ siret : "11009001600053" ,
55
+ } ,
56
+ ] ;
57
+
51
58
export const getJoinOrganizationController = async (
52
59
req : Request ,
53
60
res : Response ,
@@ -60,7 +67,7 @@ export const getJoinOrganizationController = async (
60
67
do_not_propose_suggestions : optionalBooleanSchema ( ) ,
61
68
} ) ;
62
69
63
- const { notification, siret_hint, do_not_propose_suggestions } =
70
+ let { notification, siret_hint, do_not_propose_suggestions } =
64
71
await schema . parseAsync ( req . query ) ;
65
72
66
73
const { id : user_id , email } = getUserFromAuthenticatedSession ( req ) ;
@@ -74,13 +81,23 @@ export const getJoinOrganizationController = async (
74
81
return res . redirect ( "/users/organization-suggestions" ) ;
75
82
}
76
83
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
+
77
95
return res . render ( "user/join-organization" , {
78
96
pageTitle : "Rejoindre une organisation" ,
79
97
notifications : await getNotificationsFromRequest ( req ) ,
80
98
csrfToken : csrfToken ( req ) ,
81
99
siretHint : siret_hint ,
82
- useGendarmerieSearchHint :
83
- getEmailDomain ( email ) === "gendarmerie.interieur.gouv.fr" ,
100
+ useGendarmerieSearchHint : emailDomain === "gendarmerie.interieur.gouv.fr" ,
84
101
} ) ;
85
102
} catch ( error ) {
86
103
next ( error ) ;
0 commit comments