diff --git a/server/modules/users/server/controllers/admin.server.controller.js b/server/modules/users/server/controllers/admin.server.controller.js index 20fc9c72c..17cc68dea 100644 --- a/server/modules/users/server/controllers/admin.server.controller.js +++ b/server/modules/users/server/controllers/admin.server.controller.js @@ -26,6 +26,8 @@ exports.update = function (req, res) { user.lastName = req.body.lastName; user.displayName = user.firstName + ' ' + user.lastName; user.roles = req.body.roles; + user.email = req.body.email; + user.profileImageURL = req.body.profileImageURL; user.save(function (err) { if (err) { 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 ab96ae161..64fb34aff 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 @@ -42,8 +42,9 @@ exports.signup = async function (req, res, next) { * Signin after passport authentication */ exports.signin = async function (req, res) { - const { _id, firstName, lastName, email, username, roles } = req.user; - const payload = { id: _id, firstName, lastName, email, username, roles }; + console.log(req.user); + const { id, firstName, lastName, email, username, roles, profileImageURL } = req.user; + const payload = { id, firstName, lastName, email, username, roles, profileImageURL }; const token = jwt.sign(payload, configuration.jwt.secret); return res.status(200) .cookie('TOKEN', token) 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 77fce259d..2a6f49fda 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 @@ -13,7 +13,7 @@ var _ = require('lodash'), User = mongoose.model('User'), validator = require('validator'); -var whitelistedFields = ['firstName', 'lastName', 'email', 'username']; +var whitelistedFields = ['firstName', 'lastName', 'email', 'username', 'profileImageURL']; /** * Update user details @@ -146,6 +146,7 @@ exports.me = function (req, res) { var safeUserObject = null; if (req.user) { safeUserObject = { + id: req.user.id, displayName: validator.escape(req.user.displayName), provider: validator.escape(req.user.provider), username: validator.escape(req.user.username), @@ -158,6 +159,5 @@ exports.me = function (req, res) { additionalProvidersData: req.user.additionalProvidersData }; } - res.json(safeUserObject || null); }; diff --git a/server/modules/users/server/models/mongoose/user.server.model.js b/server/modules/users/server/models/mongoose/user.server.model.js index 8c82747b3..2de04f8ff 100644 --- a/server/modules/users/server/models/mongoose/user.server.model.js +++ b/server/modules/users/server/models/mongoose/user.server.model.js @@ -89,7 +89,7 @@ var UserSchema = new Schema({ }, profileImageURL: { type: String, - default: 'modules/users/client/img/profile/default.png' + default: 'assets/ic_profile.png' }, provider: { type: String, diff --git a/server/modules/users/server/services/user.service.js b/server/modules/users/server/services/user.service.js index d13cf6645..98dc34361 100644 --- a/server/modules/users/server/services/user.service.js +++ b/server/modules/users/server/services/user.service.js @@ -28,6 +28,7 @@ class UserService { email: user.email, provider: user.provider, roles: user.roles, + profileImageURL: user.profileImageURL, created: user.created, } } @@ -39,7 +40,6 @@ class UserService { static async authenticate (email, password) { const user = await UserRepository.getByEmail(email) - if (!user) { throw new Error('invalid user or password') }