diff --git a/lib/usermanager.js b/lib/usermanager.js index e9d7936886..82da646322 100644 --- a/lib/usermanager.js +++ b/lib/usermanager.js @@ -204,7 +204,6 @@ exports = module.exports = { if (!user.email || 'string' !== typeof user.email) { return callback(new UserEmailError('user email is required!')); } - database.getDatabase(function(err, db){ if (err) { return callback(err); @@ -220,6 +219,8 @@ exports = module.exports = { // user exists return callback(new DuplicateUserError()); } else { + // ensure email is lower case + user.email = user.email.toLowerCase(); db.create('user', user, function (error, result) { // Wrap the callback since we might want to alter the result if (error) { @@ -261,7 +262,9 @@ exports = module.exports = { callback = options; options = {}; } - + if(search.email) { + search.email = search.email.toLowerCase(); + } database.getDatabase(function(err,db) { db.retrieve('user', search, options, function (error, results) { if (error) { @@ -300,6 +303,9 @@ exports = module.exports = { return callback(new Error('No matching user record found')); } database.getDatabase(function(err, db) { + if(update.email) { + updateEmail = update.email.toLowerCase(); + } if (update.email !== self.getCurrentUser().email) { // email updated, verify the new email does not already exist db.retrieve('user', { email: update.email }, function (error, results) {