Vulcan/packages/telescope-users/lib/methods.js

20 lines
571 B
JavaScript
Raw Normal View History

2015-05-06 12:28:00 +09:00
Meteor.methods({
// not used for now
changeEmail: function (userId, newEmail) {
var user = Meteor.users.findOne(userId);
if (Users.can.edit(Meteor.user(), user) !== true) {
throw new Meteor.Error("Permission denied");
}
Meteor.users.update(
userId,
{$set: {
emails: [{address: newEmail, verified: false}],
emailHash: Gravatar.hash(newEmail),
// Just in case this gets called from somewhere other than /client/views/users/user_edit.js
"profile.email": newEmail
}
}
);
}
});