Skip to content

Commit

Permalink
feat(users): add position to model ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Nov 16, 2020
1 parent b5042d0 commit 41cd8fc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions config/defaults/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module.exports = {
'firstName',
'lastName',
'bio',
'position',
'email',
'avatar',
'roles',
Expand All @@ -126,8 +127,8 @@ module.exports = {
'resetPasswordExpires',
'complementary',
],
update: ['firstName', 'lastName', 'bio', 'email', 'avatar', 'complementary'],
updateAdmin: ['firstName', 'lastName', 'bio', 'email', 'avatar', 'roles', 'complementary'],
update: ['firstName', 'lastName', 'bio', 'position', 'email', 'avatar', 'complementary'],
updateAdmin: ['firstName', 'lastName', 'bio', 'position', 'email', 'avatar', 'roles', 'complementary'],
recover: ['password', 'resetPasswordToken', 'resetPasswordExpires'],
roles: ['user', 'admin'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ exports.me = (req, res) => {
complementary: req.user.complementary,
};
if (req.user.bio) user.bio = req.user.bio;
if (req.user.position) user.position = req.user.position;
}
return responses.success(res, 'user get')(user);
};
3 changes: 2 additions & 1 deletion modules/users/models/user.model.mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const UserMongoose = new Schema({
firstName: String,
lastName: String,
bio: String,
position: String,
email: {
type: String,
unique: 'Email already exists',
Expand All @@ -27,7 +28,7 @@ const UserMongoose = new Schema({
password: String,
resetPasswordToken: String,
resetPasswordExpires: Date,
complementary: {}, // put your specific project data here
complementary: {}, // put your specific project private data here
}, {
timestamps: true,
});
Expand Down
4 changes: 4 additions & 0 deletions modules/users/models/user.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const UserSchema = Joi.object().keys({
.trim()
.allow('')
.optional(),
position: Joi.string().max(50)
.trim()
.allow('')
.optional(),
email: Joi.string().email(),
avatar: Joi.string().trim().default('').allow(''),
roles: Joi.array().items(Joi.string().valid(...config.whitelists.users.roles)).min(1).default(['user']),
Expand Down

0 comments on commit 41cd8fc

Please sign in to comment.