Skip to content

Commit 25ec508

Browse files
committed
Reset by code catch errors
1 parent ab209cf commit 25ec508

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/management/passwd/passwd.controller.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,23 @@ export class PasswdController {
4848
public async resetbycode(@Body() body: ResetByCodeDto, @Res() res: Response): Promise<Response> {
4949
const debug = {};
5050
this.logger.log('Reset by code : ' + body.token + ' code : ' + body.code);
51-
const [_, data] = await this.passwdService.resetByCode(body);
52-
if (process.env.NODE_ENV === 'development') {
53-
debug['_debug'] = data;
51+
try{
52+
const [_, data] = await this.passwdService.resetByCode(body);
53+
if (process.env.NODE_ENV === 'development') {
54+
debug['_debug'] = data;
55+
}
56+
57+
return res.status(HttpStatus.OK).json({
58+
message: 'Password changed',
59+
...debug,
60+
});
61+
}catch(e){
62+
return res.status(HttpStatus.BAD_REQUEST).json({
63+
message: 'Erreur serveur',
64+
...debug,
65+
});
5466
}
5567

56-
return res.status(HttpStatus.OK).json({
57-
message: 'Password changed',
58-
...debug,
59-
});
6068
}
6169

6270
@Post('reset')

0 commit comments

Comments
 (0)