Update: User.controller.auth
This commit is contained in:
parent
d740beda4e
commit
4ebbd04c99
1 changed files with 1 additions and 2 deletions
|
|
@ -13,10 +13,9 @@ exports.auth = (req, res) => {
|
||||||
} else{
|
} else{
|
||||||
// Check User in the database
|
// Check User in the database
|
||||||
User
|
User
|
||||||
.findOne({email: req.body.email, hashPass: req.body.hashPass, isActive: true}, {role: true})
|
.findOne({email: req.body.email, hashPass: req.body.hashPass, isActive: true}, {role: true, profileImageUrl: true})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data !== null){
|
if (data !== null){
|
||||||
console.log(data._id.toString(), {lastConnexion: new Date()});
|
|
||||||
User.findByIdAndUpdate(data._id.toString(), {lastConnexion: new Date()}, {useFindAndModify: false});
|
User.findByIdAndUpdate(data._id.toString(), {lastConnexion: new Date()}, {useFindAndModify: false});
|
||||||
const dataRes = {id: data._id.toString(), email: req.body.email, profileImageUrl: data.profileImageUrl, role: data.role};
|
const dataRes = {id: data._id.toString(), email: req.body.email, profileImageUrl: data.profileImageUrl, role: data.role};
|
||||||
setSessionCookie(req, res, dataRes);
|
setSessionCookie(req, res, dataRes);
|
||||||
|
|
|
||||||
Reference in a new issue