Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Refactor variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
shanavas786 committed Aug 17, 2016
1 parent 8bfd74a commit 9a412e1
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@ var _ = require('lodash'),
config = require(path.resolve('./config/config')),
User = mongoose.model('User');

var whitelistedFields = ['firstName', 'lastName', 'email', 'username'];

/**
* Update user details
*/
exports.update = function (req, res) {
// Init Variables
var user = req.user;
var secureFields = ['firstName', 'lastName', 'email', 'username'];

if (user) {
// For security measurements update only secure fields
secureFields.forEach(function (field) {
if (req.body.hasOwnProperty(field)) {
user[field] = req.body[field];
}
});
// Update whitelisted fields only
user = _.extend(user, _.pick(req.body, whitelistedFields));

user.updated = Date.now();
user.displayName = user.firstName + ' ' + user.lastName;
Expand Down

0 comments on commit 9a412e1

Please sign in to comment.