@@ -43,44 +43,8 @@ const AnalyticsGuestTokenRequestOptions = {
4343export const authenticationController : FastifyPluginAsyncTypebox = async (
4444 app ,
4545) => {
46- app . post ( '/sign-up' , SignUpRequestOptions , async ( request , reply ) => {
47- const user = await userService . getMetaInfo ( {
48- id : request . principal . id ,
49- } ) ;
50-
51- if ( ! user || user . email !== adminEmail ) {
52- return reply . code ( 403 ) . send ( {
53- statusCode : 403 ,
54- error : 'Insufficient Permissions' ,
55- message : 'Adding new users only allowed to admin user.' ,
56- } ) ;
57- }
58-
59- const signUpResponse = await authenticationService . signUp ( {
60- ...request . body ,
61- verified : edition === OpsEdition . COMMUNITY ,
62- organizationId : null ,
63- provider : Provider . EMAIL ,
64- } ) ;
65-
66- return setAuthCookiesAndReply ( reply , signUpResponse ) ;
67- } ) ;
68-
69- app . post ( '/sign-in' , SignInRequestOptions , async ( request , reply ) => {
70- const organizationId = await resolveOrganizationIdForAuthnRequest (
71- request . body . email ,
72- request ,
73- ) ;
74-
75- const signInResponse = await authenticationService . signIn ( {
76- email : request . body . email ,
77- password : request . body . password ,
78- organizationId,
79- provider : Provider . EMAIL ,
80- } ) ;
81-
82- return setAuthCookiesAndReply ( reply , signInResponse ) ;
83- } ) ;
46+ app . post ( '/sign-up' , SignUpRequestOptions , signUpRoute ) ;
47+ app . post ( '/sign-in' , SignInRequestOptions , signInRoute ) ;
8448
8549 app . post (
8650 '/sign-out' ,
@@ -122,6 +86,47 @@ export const authenticationController: FastifyPluginAsyncTypebox = async (
12286 ) ;
12387} ;
12488
89+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
90+ const signUpRoute = async ( request : any , reply : any ) => {
91+ const user = await userService . getMetaInfo ( {
92+ id : request . principal . id ,
93+ } ) ;
94+
95+ if ( ! user || user . email !== adminEmail ) {
96+ return reply . code ( 403 ) . send ( {
97+ statusCode : 403 ,
98+ error : 'Insufficient Permissions' ,
99+ message : 'Adding new users only allowed to admin user.' ,
100+ } ) ;
101+ }
102+
103+ const signUpResponse = await authenticationService . signUp ( {
104+ ...request . body ,
105+ verified : edition === OpsEdition . COMMUNITY ,
106+ organizationId : null ,
107+ provider : Provider . EMAIL ,
108+ } ) ;
109+
110+ return setAuthCookiesAndReply ( reply , signUpResponse ) ;
111+ } ;
112+
113+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
114+ const signInRoute = async ( request : any , reply : any ) => {
115+ const organizationId = await resolveOrganizationIdForAuthnRequest (
116+ request . body . email ,
117+ request ,
118+ ) ;
119+
120+ const signInResponse = await authenticationService . signIn ( {
121+ email : request . body . email ,
122+ password : request . body . password ,
123+ organizationId,
124+ provider : Provider . EMAIL ,
125+ } ) ;
126+
127+ return setAuthCookiesAndReply ( reply , signInResponse ) ;
128+ } ;
129+
125130const rateLimitOptions : RateLimitOptions = {
126131 max : Number . parseInt (
127132 system . getOrThrow ( AppSystemProp . API_RATE_LIMIT_AUTHN_MAX ) ,
0 commit comments