Skip to content

Commit

Permalink
niko changes at my place
Browse files Browse the repository at this point in the history
  • Loading branch information
tutaru99 committed May 21, 2021
1 parent 3c85c0c commit 5dcb934
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ exports.login = async (req, res) => {
});
}

req.login(user, { session: false }, (err) => {
req.login(user, { session: false }, async (err) => {
if (err) {
res.send(err);
}
Expand All @@ -62,7 +62,16 @@ exports.login = async (req, res) => {
}
);

res.status(200).send({ username: user.username, id: user._id, token });
await db.users
.findById(user._id)
.then((result) => {
const email = result.email;
res.status(200).send({ username: user.username, id: user._id, token, email });
})
.catch((error) => {
console.log(error);
res.status(400).json('Unexpected error');
});
});
}
)(req, res);
Expand Down

0 comments on commit 5dcb934

Please sign in to comment.