diff --git a/server/modules/users/server/controllers/users/users.authentication.server.controller.js b/server/modules/users/server/controllers/users/users.authentication.server.controller.js index eb0d7c056..ab96ae161 100644 --- a/server/modules/users/server/controllers/users/users.authentication.server.controller.js +++ b/server/modules/users/server/controllers/users/users.authentication.server.controller.js @@ -27,12 +27,12 @@ var noReturnUrls = [ exports.signup = async function (req, res, next) { try { const user = await UserService.signUp(req.body) - const { _id, firstName, lastName, email, username } = user - const payload = { id: _id, firstName, lastName, email, username } + const { _id, firstName, lastName, email, username, roles } = user; + const payload = { id: _id, firstName, lastName, email, username, roles } const token = jwt.sign(payload, config.jwt.secret) return res.status(200) .cookie('TOKEN', token, { maxAge: 900000, httpOnly: true }) - .json({ user: payload, tokenExpiresIn: 101010010101 }) + .json({ user: payload, tokenExpiresIn: (new Date(Date.now() + 60 * 60 * 24 * 1000)).getTime() }) } catch(err) { return next(new ApiError(err.message)) } @@ -42,12 +42,12 @@ exports.signup = async function (req, res, next) { * Signin after passport authentication */ exports.signin = async function (req, res) { - const { _id, firstName, lastName, email, username } = req.user; - const payload = { id: _id, firstName, lastName, email, username }; + const { _id, firstName, lastName, email, username, roles } = req.user; + const payload = { id: _id, firstName, lastName, email, username, roles }; const token = jwt.sign(payload, configuration.jwt.secret); return res.status(200) .cookie('TOKEN', token) - .json({ user: payload, tokenExpiresIn: 10101010101 }); + .json({ user: payload, tokenExpiresIn: (new Date(Date.now() + 60 * 60 * 24 * 1000)).getTime() }); }; /** diff --git a/server/modules/users/server/controllers/users/users.profile.server.controller.js b/server/modules/users/server/controllers/users/users.profile.server.controller.js index e1978c3c8..77fce259d 100644 --- a/server/modules/users/server/controllers/users/users.profile.server.controller.js +++ b/server/modules/users/server/controllers/users/users.profile.server.controller.js @@ -28,8 +28,7 @@ exports.update = function (req, res) { user.updated = Date.now(); user.displayName = user.firstName + ' ' + user.lastName; - - user.save(function (err) { + User.findByIdAndUpdate(user.id, user, function (err) { if (err) { return res.status(422).send({ message: errorHandler.getErrorMessage(err) diff --git a/server/modules/users/server/services/user.service.js b/server/modules/users/server/services/user.service.js index 9211949c0..d13cf6645 100644 --- a/server/modules/users/server/services/user.service.js +++ b/server/modules/users/server/services/user.service.js @@ -27,6 +27,7 @@ class UserService { username: user.username, email: user.email, provider: user.provider, + roles: user.roles, created: user.created, } }