Add userId param to changeEmail method

Fixes #852.
This commit is contained in:
Charlie DeTar 2015-03-26 14:39:36 -06:00
parent db49d9746c
commit 7015663741
2 changed files with 8 additions and 4 deletions

View file

@ -89,7 +89,7 @@ Template[getTemplate('userAccount')].events({
});
});
Meteor.call('changeEmail', email);
Meteor.call('changeEmail', user._id, email);
}

View file

@ -57,11 +57,15 @@ Accounts.onCreateUser(function(options, user){
Meteor.methods({
changeEmail: function (newEmail) {
changeEmail: function (userId, newEmail) {
var user = Meteor.users.findOne(userId);
if (can.edit(user) !== true) {
throw new Meteor.Error("Permission denied");
}
Meteor.users.update(
Meteor.userId(),
userId,
{$set: {
emails: [{address: newEmail}],
emails: [{address: newEmail, verified: false}],
email_hash: Gravatar.hash(newEmail),
// Just in case this gets called from somewhere other than /client/views/users/user_edit.js
"profile.email": newEmail