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

Commit

Permalink
Add flexibility for 'name' property definition in users
Browse files Browse the repository at this point in the history
  • Loading branch information
gvilarino committed Jul 30, 2014
1 parent fa00cc5 commit 35ac439
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion source/jobs/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ var db = require('../db')(config);

var ObjectId = require('mongojs').ObjectId;

function normalize (user) {
if (!user.name && user.firstName) {
user.name = user.firstName;
}
return user;
}

var resolvers = {
'send-welcome': function (action, callback) {
db.users.findOne({email: action.user}, function (err, user) {
Expand All @@ -14,10 +21,12 @@ var resolvers = {
return callback({message: 'user not found', email: action.email});
}

callback(null, action, {email: action.user, user: user, validateUrl: action.validateUrl});
callback(null, action, {email: action.user, user: normalize(user), validateUrl: action.validateUrl});
});
},

// TODO: check these later

'send-personal': function (action, callback) {
db.users.findOne({email: action.user}, function (err, user) {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion source/templates/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function jadeTemplate(name, vars, callback) {
} else {
callback(err);
}
});
});
};

function replaceVars(template, vars) {
Expand Down

0 comments on commit 35ac439

Please sign in to comment.