Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflict #11

Merged
merged 1 commit into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -158,6 +159,5 @@ exports.me = function (req, res) {
additionalProvidersData: req.user.additionalProvidersData
};
}

res.json(safeUserObject || null);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion server/modules/users/server/services/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class UserService {
email: user.email,
provider: user.provider,
roles: user.roles,
profileImageURL: user.profileImageURL,
created: user.created,
}
}
Expand All @@ -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')
}
Expand Down