translated error

This commit is contained in:
2024-10-31 08:29:56 +03:00
parent c950882e0e
commit d4233c72f5
2 changed files with 3 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import AbstractProductService from '../services/abstractproduct.js';
import ProductService from '../services/product.js';
import translate from '../utils/translate.js';
import responseCodes from '../response/responseCodes.js';
import customError from '../response/customError.js';
const TAG = "/controllers/userjs"
@@ -23,7 +24,7 @@ class UserController {
const { username, password } = req.body;
const user = await UserService.getByUsername(username);
if (!bcrypt.compareSync(password, user.password)) return res.status(401).send("Wrong password");
if (!bcrypt.compareSync(password, user.password)) throw new customError(`Wrong user password`, responseCodes.responses.passwords.invalid);
const token = genToken(user);
return res.status(200).send(token);