File tree Expand file tree Collapse file tree 3 files changed +4
-25
lines changed
Expand file tree Collapse file tree 3 files changed +4
-25
lines changed Original file line number Diff line number Diff line change 1- import { BaseIsomerError } from "@root/errors/BaseError"
2-
31const autoBind = require ( "auto-bind" )
42const express = require ( "express" )
53
@@ -109,12 +107,6 @@ class AuthRouter {
109107 } )
110108 const email = rawEmail . toLowerCase ( )
111109 const userIp = isSecure ? req . get ( "cf-connecting-ip" ) : req . ip
112- if ( ! userIp ) {
113- throw new BaseIsomerError ( {
114- status : 500 ,
115- message : "No user IP found in the request" ,
116- } )
117- }
118110 const userInfo = (
119111 await this . authService . verifyOtp ( { email, otp, clientIp : userIp } )
120112 ) . value
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import { attachReadRouteHandlerWrapper } from "@middleware/routeHandler"
1111
1212import UserSessionData from "@classes/UserSessionData"
1313
14- import { BaseIsomerError } from "@root/errors/BaseError"
1514import DatabaseError from "@root/errors/DatabaseError"
1615import { isError , RequestHandler } from "@root/types"
1716import { nameAnonymousMethods } from "@root/utils/apm-utils"
@@ -86,12 +85,6 @@ export class UsersRouter {
8685 const parsedEmail = email . toLowerCase ( )
8786
8887 const userIp = isSecure ? req . get ( "cf-connecting-ip" ) : req . ip
89- if ( ! userIp ) {
90- throw new BaseIsomerError ( {
91- status : 500 ,
92- message : "No user IP found in the request" ,
93- } )
94- }
9588 return this . usersService
9689 . verifyEmailOtp ( parsedEmail , otp , userIp )
9790 . andThen ( ( ) =>
@@ -152,12 +145,6 @@ export class UsersRouter {
152145 const userId = userSessionData . isomerUserId
153146
154147 const userIp = isSecure ? req . get ( "cf-connecting-ip" ) : req . ip
155- if ( ! userIp ) {
156- throw new BaseIsomerError ( {
157- status : 500 ,
158- message : "No user IP found in the request" ,
159- } )
160- }
161148 return this . usersService
162149 . verifyMobileOtp ( mobile , otp , userIp )
163150 . andThen ( ( ) =>
Original file line number Diff line number Diff line change @@ -273,12 +273,12 @@ class UsersService {
273273 otp,
274274 findConditions,
275275 findErrorMessage,
276- clientIp,
276+ clientIp = "unknown" , // default to 'unknown' bucket when IP missing to ensure users are not locked out
277277 } : {
278278 otp : string | undefined
279279 findConditions : { email : string } | { mobileNumber : string }
280280 findErrorMessage : string
281- clientIp : string
281+ clientIp ? : string
282282 } ) {
283283 if ( ! otp ) {
284284 return errAsync ( new BadRequestError ( "Empty OTP provided" ) )
@@ -391,7 +391,7 @@ class UsersService {
391391 /* eslint-enable @typescript-eslint/no-non-null-assertion */
392392 }
393393
394- verifyEmailOtp ( email : string , otp : string | undefined , clientIp : string ) {
394+ verifyEmailOtp ( email : string , otp : string | undefined , clientIp ? : string ) {
395395 const normalizedEmail = email . toLowerCase ( )
396396
397397 return this . verifyOtp ( {
@@ -405,7 +405,7 @@ class UsersService {
405405 verifyMobileOtp (
406406 mobileNumber : string ,
407407 otp : string | undefined ,
408- clientIp : string
408+ clientIp ? : string
409409 ) {
410410 return this . verifyOtp ( {
411411 otp,
You can’t perform that action at this time.
0 commit comments