@@ -114,16 +114,27 @@ 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 ( {
122128 statusCode :
123129 ENUM_USER_STATUS_CODE_ERROR . USER_PASSWORD_NOT_MATCH_ERROR ,
124130 message : 'user.error.passwordNotMatch' ,
125131 } ) ;
126- } else if ( ! user . isActive ) {
132+ } else if ( user . blocked ) {
133+ throw new ForbiddenException ( {
134+ statusCode : ENUM_USER_STATUS_CODE_ERROR . USER_BLOCKED_ERROR ,
135+ message : 'user.error.blocked' ,
136+ } ) ;
137+ } else if ( ! user . isActive || user . inactivePermanent ) {
127138 throw new ForbiddenException ( {
128139 statusCode : ENUM_USER_STATUS_CODE_ERROR . USER_INACTIVE_ERROR ,
129140 message : 'user.error.inactive' ,
@@ -135,16 +146,14 @@ export class UserController {
135146 } ) ;
136147 }
137148
138- if ( passwordAttempt ) {
139- try {
140- await this . userService . resetPasswordAttempt ( user . _id ) ;
141- } catch ( err : any ) {
142- throw new InternalServerErrorException ( {
143- statusCode : ENUM_ERROR_STATUS_CODE_ERROR . ERROR_UNKNOWN ,
144- message : 'http.serverError.internalServerError' ,
145- _error : err . message ,
146- } ) ;
147- }
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+ } ) ;
148157 }
149158
150159 const payload : UserPayloadSerialization =
@@ -235,7 +244,12 @@ export class UserController {
235244 statusCode : ENUM_USER_STATUS_CODE_ERROR . USER_NOT_FOUND_ERROR ,
236245 message : 'user.error.notFound' ,
237246 } ) ;
238- } else if ( ! user . isActive ) {
247+ } else if ( user . blocked ) {
248+ throw new ForbiddenException ( {
249+ statusCode : ENUM_USER_STATUS_CODE_ERROR . USER_BLOCKED_ERROR ,
250+ message : 'user.error.blocked' ,
251+ } ) ;
252+ } else if ( ! user . isActive || user . inactivePermanent ) {
239253 throw new ForbiddenException ( {
240254 statusCode : ENUM_USER_STATUS_CODE_ERROR . USER_INACTIVE_ERROR ,
241255 message : 'user.error.inactive' ,
@@ -326,8 +340,14 @@ export class UserController {
326340 user . password
327341 ) ;
328342 if ( ! matchPassword ) {
329- if ( passwordAttempt ) {
343+ try {
330344 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+ } ) ;
331351 }
332352
333353 throw new BadRequestException ( {
@@ -349,16 +369,14 @@ export class UserController {
349369 } ) ;
350370 }
351371
352- if ( passwordAttempt ) {
353- try {
354- await this . userService . increasePasswordAttempt ( user ) ;
355- } catch ( err : any ) {
356- throw new InternalServerErrorException ( {
357- statusCode : ENUM_ERROR_STATUS_CODE_ERROR . ERROR_UNKNOWN ,
358- message : 'http.serverError.internalServerError' ,
359- _error : err . message ,
360- } ) ;
361- }
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+ } ) ;
362380 }
363381
364382 try {
0 commit comments