now sending userid on login and register

This commit is contained in:
2024-11-03 02:41:13 +03:00
parent 0b32306f84
commit 69c2255614
2 changed files with 7 additions and 5 deletions

View File

@@ -15,10 +15,10 @@ class UserController {
async register(req, res) {
const { username, password } = req.body;
await UserService.create(username, password);
let userId = await UserService.create(username, password);
log.info(`New user with name ${username} has just registered`);
return res.status(200).send(translate(req.headers["accept-language"], responseCodes.responses.general.ok));
return res.status(200).send(userId.toString());
}
async login(req, res) {
@@ -28,7 +28,7 @@ class UserController {
if (!bcrypt.compareSync(password, user.password)) throw new customError(`Wrong user password`, responseCodes.responses.passwords.invalid);
const token = jwtutils.genToken(user);
return res.status(200).send(token);
return res.status(200).send({ id: user.id, token: token });
}
async synchronize(req, res) {