Skip to content

Commit

Permalink
Add verification for oldPassword
Browse files Browse the repository at this point in the history
  • Loading branch information
Isthisanmol committed Aug 24, 2024
1 parent bf1ddfa commit ac43b80
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/src/controllers/auth/updatePassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export function updatePasswordRoute() {
return protectedProcedure
.input(validator.updatePassword)
.mutation(async (opts) => {
const { email, password } = opts.input;
const { email, oldPassword, password } = opts.rawInput;
const { env }: any = opts.ctx;
const JWT_SECRET = env.JWT_SECRET;
const userClass = new User();
const user = await userClass.findByCredentials(email, password);
const user = await userClass.findByCredentials(email, oldPassword);
if (!user) {
throw new Error('Password is not correct');
throw new Error('Old password is incorrect');
}
const hashedPassword = await hashPassword(JWT_SECRET, password);
const currentUser = await findUserAndUpdate(
Expand Down

0 comments on commit ac43b80

Please sign in to comment.