Skip to content

Commit dad0e99

Browse files
committed
feat: add a security measure to forgot-password
1 parent 7826104 commit dad0e99

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/modules/auth/auth.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const refreshTokens = catchAsync(async (req: Request, res: Response) => {
3232
export const forgotPassword = catchAsync(async (req: Request, res: Response) => {
3333
const resetPasswordToken = await tokenService.generateResetPasswordToken(req.body.email);
3434
await emailService.sendResetPasswordEmail(req.body.email, resetPasswordToken);
35-
res.status(httpStatus.NO_CONTENT).send();
35+
res.status(httpStatus.NO_CONTENT).send('');
3636
});
3737

3838
export const resetPassword = catchAsync(async (req: Request, res: Response) => {

src/modules/token/token.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const generateAuthTokens = async (user: IUserDoc): Promise<AccessAndRefre
115115
export const generateResetPasswordToken = async (email: string): Promise<string> => {
116116
const user = await userService.getUserByEmail(email);
117117
if (!user) {
118-
throw new ApiError(httpStatus.NOT_FOUND, 'No users found with this email');
118+
throw new ApiError(httpStatus.NO_CONTENT, '');
119119
}
120120
const expires = moment().add(config.jwt.resetPasswordExpirationMinutes, 'minutes');
121121
const resetPasswordToken = generateToken(user.id, expires, tokenTypes.RESET_PASSWORD);

0 commit comments

Comments
 (0)