Update auth-password-service.ts

This commit is contained in:
Daniel Hougaard
2025-05-20 17:47:47 +04:00
parent 1f85d9c486
commit 677180548b
@@ -189,16 +189,15 @@ export const authPaswordServiceFactory = ({
throw new BadRequestError({ message: `User encryption key not found for user with ID '${userId}'` }); throw new BadRequestError({ message: `User encryption key not found for user with ID '${userId}'` });
} }
if (!user.hashedPassword) {
throw new BadRequestError({ message: "Unable to reset password, no password is set" });
}
if (!user.authMethods?.includes(AuthMethod.EMAIL)) { if (!user.authMethods?.includes(AuthMethod.EMAIL)) {
throw new BadRequestError({ message: "Unable to reset password, no email authentication method is configured" }); throw new BadRequestError({ message: "Unable to reset password, no email authentication method is configured" });
} }
// we check the old password if the user is resetting their password while logged in // we check the old password if the user is resetting their password while logged in
if (type === ResetPasswordV2Type.LoggedInReset) { if (type === ResetPasswordV2Type.LoggedInReset) {
if (!user.hashedPassword) {
throw new BadRequestError({ message: "Unable to change password, no password is set" });
}
if (!oldPassword) { if (!oldPassword) {
throw new BadRequestError({ message: "Current password is required." }); throw new BadRequestError({ message: "Current password is required." });
} }