HM-129. Правки ошибки не верного старого пароля

This commit is contained in:
vigdorov
2020-09-10 22:24:50 +03:00
parent 6e3f003cd4
commit 5dd2646d1a

View File

@ -248,7 +248,10 @@ export class UserService {
throw new BadRequestException('Запрещено менять пароль пользователя admin');
}
const user = await this.userModel().findOne({login});
if (user && await this.checkPassword(old_password, user.password)) {
if (!await this.checkPassword(old_password, user.password)) {
throw new BadRequestException('Не верный старый пароль');
}
if (user) {
const salt = user.salt;
const password = await bcrypt.hash(new_password, salt);
await user.updateOne({