@@ -114,8 +114,14 @@ export class UserController {
114114 user . password
115115 ) ;
116116 if ( ! validate ) {
117- if ( passwordAttempt ) {
117+ try {
118118 await this . userService . increasePasswordAttempt ( user ) ;
119+ } catch ( err : any ) {
120+ throw new InternalServerErrorException ( {
121+ statusCode : ENUM_ERROR_STATUS_CODE_ERROR . ERROR_UNKNOWN ,
122+ message : 'http.serverError.internalServerError' ,
123+ _error : err . message ,
124+ } ) ;
119125 }
120126
121127 throw new BadRequestException ( {
@@ -140,16 +146,14 @@ export class UserController {
140146 } ) ;
141147 }
142148
143- if ( passwordAttempt ) {
144- try {
145- await this . userService . resetPasswordAttempt ( user . _id ) ;
146- } catch ( err : any ) {
147- throw new InternalServerErrorException ( {
148- statusCode : ENUM_ERROR_STATUS_CODE_ERROR . ERROR_UNKNOWN ,
149- message : 'http.serverError.internalServerError' ,
150- _error : err . message ,
151- } ) ;
152- }
149+ try {
150+ await this . userService . resetPasswordAttempt ( user . _id ) ;
151+ } catch ( err : any ) {
152+ throw new InternalServerErrorException ( {
153+ statusCode : ENUM_ERROR_STATUS_CODE_ERROR . ERROR_UNKNOWN ,
154+ message : 'http.serverError.internalServerError' ,
155+ _error : err . message ,
156+ } ) ;
153157 }
154158
155159 const payload : UserPayloadSerialization =
@@ -336,8 +340,14 @@ export class UserController {
336340 user . password
337341 ) ;
338342 if ( ! matchPassword ) {
339- if ( passwordAttempt ) {
343+ try {
340344 await this . userService . increasePasswordAttempt ( user ) ;
345+ } catch ( err : any ) {
346+ throw new InternalServerErrorException ( {
347+ statusCode : ENUM_ERROR_STATUS_CODE_ERROR . ERROR_UNKNOWN ,
348+ message : 'http.serverError.internalServerError' ,
349+ _error : err . message ,
350+ } ) ;
341351 }
342352
343353 throw new BadRequestException ( {
@@ -359,16 +369,14 @@ export class UserController {
359369 } ) ;
360370 }
361371
362- if ( passwordAttempt ) {
363- try {
364- await this . userService . resetPasswordAttempt ( user . _id ) ;
365- } catch ( err : any ) {
366- throw new InternalServerErrorException ( {
367- statusCode : ENUM_ERROR_STATUS_CODE_ERROR . ERROR_UNKNOWN ,
368- message : 'http.serverError.internalServerError' ,
369- _error : err . message ,
370- } ) ;
371- }
372+ try {
373+ await this . userService . resetPasswordAttempt ( user . _id ) ;
374+ } catch ( err : any ) {
375+ throw new InternalServerErrorException ( {
376+ statusCode : ENUM_ERROR_STATUS_CODE_ERROR . ERROR_UNKNOWN ,
377+ message : 'http.serverError.internalServerError' ,
378+ _error : err . message ,
379+ } ) ;
372380 }
373381
374382 try {
0 commit comments