File tree Expand file tree Collapse file tree 4 files changed +35
-3
lines changed
repositories/organization Expand file tree Collapse file tree 4 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ export const getJoinOrganizationController = async (
60
60
do_not_propose_suggestions : optionalBooleanSchema ( ) ,
61
61
} ) ;
62
62
63
- const { notification, siret_hint, do_not_propose_suggestions } =
63
+ let { notification, siret_hint, do_not_propose_suggestions } =
64
64
await schema . parseAsync ( req . query ) ;
65
65
66
66
const { id : user_id , email } = getUserFromAuthenticatedSession ( req ) ;
@@ -74,13 +74,14 @@ export const getJoinOrganizationController = async (
74
74
return res . redirect ( "/users/organization-suggestions" ) ;
75
75
}
76
76
77
+ const emailDomain = getEmailDomain ( email ) ;
78
+
77
79
return res . render ( "user/join-organization" , {
78
80
pageTitle : "Rejoindre une organisation" ,
79
81
notifications : await getNotificationsFromRequest ( req ) ,
80
82
csrfToken : csrfToken ( req ) ,
81
83
siretHint : siret_hint ,
82
- useGendarmerieSearchHint :
83
- getEmailDomain ( email ) === "gendarmerie.interieur.gouv.fr" ,
84
+ useGendarmerieSearchHint : emailDomain === "gendarmerie.interieur.gouv.fr" ,
84
85
} ) ;
85
86
} catch ( error ) {
86
87
next ( error ) ;
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ import {
53
53
findByUserId ,
54
54
findByVerifiedEmailDomain ,
55
55
getById ,
56
+ getBySiret ,
56
57
} from "../../repositories/organization/getters" ;
57
58
import {
58
59
linkUserToOrganization ,
@@ -67,6 +68,7 @@ import {
67
68
import { logger } from "../../services/log" ;
68
69
import {
69
70
hasLessThanFiftyEmployees ,
71
+ isArmeeDomain ,
70
72
isCommune ,
71
73
isEducationNationaleDomain ,
72
74
isEtablissementScolaireDuPremierEtSecondDegre ,
@@ -110,6 +112,13 @@ export const getOrganizationSuggestions = async ({
110
112
return [ ] ;
111
113
}
112
114
115
+ if ( isArmeeDomain ( domain ) ) {
116
+ const armeeOrganization = await getBySiret ( "11009001600053" ) ;
117
+ if ( armeeOrganization ) {
118
+ return [ armeeOrganization ] ;
119
+ }
120
+ }
121
+
113
122
const organizationsSuggestions = await findByVerifiedEmailDomain ( domain ) ;
114
123
115
124
if ( organizationsSuggestions . length > MAX_SUGGESTED_ORGANIZATIONS ) {
Original file line number Diff line number Diff line change @@ -17,6 +17,21 @@ export const findByUserId = findByUserIdFactory({
17
17
pg : getDatabaseConnection ( ) ,
18
18
} ) ;
19
19
20
+ export const getBySiret = async ( siret : string ) => {
21
+ const connection = getDatabaseConnection ( ) ;
22
+
23
+ const { rows } : QueryResult < Organization > = await connection . query (
24
+ `
25
+ SELECT id, siret
26
+ FROM organizations
27
+ WHERE siret = $1
28
+ ` ,
29
+ [ siret ] ,
30
+ ) ;
31
+
32
+ return rows . shift ( ) ;
33
+ } ;
34
+
20
35
export const findPendingByUserId = async ( user_id : number ) => {
21
36
const connection = getDatabaseConnection ( ) ;
22
37
Original file line number Diff line number Diff line change @@ -115,6 +115,13 @@ export const isEducationNationaleDomain = (domain: string) => {
115
115
return domain . match ( / ^ a c - [ a - z A - Z 0 - 9 - ] * \. f r $ / ) !== null ;
116
116
} ;
117
117
118
+ export const isArmeeDomain = ( domain : string ) => {
119
+ if ( ! isDomainValid ( domain ) ) {
120
+ return false ;
121
+ }
122
+ return domain === "intradef.gouv.fr" ;
123
+ } ;
124
+
118
125
export const getOrganizationTypeLabel = ( organization : Organization ) => {
119
126
if ( isEtablissementScolaireDuPremierEtSecondDegre ( organization ) ) {
120
127
return "établissement scolaire" ;
You can’t perform that action at this time.
0 commit comments