I'm working on a Meteor app, and I want to move a call to Accounts.changePassword from the client to a method. However, when I try to run the method, I get this server error :
Exception while invoking method 'setPersonalPassword' TypeError: Object [object Object] has no method 'changePassword'
This is the offending code:
'setPersonalPassword': function(oldPassword, newPassword){
Accounts.changePassword(oldPassword, newPassword);
},
However, this code works fine on the client:
'submit form': function (event) {
event.preventDefault();
var oldPassword = event.target.oldPassword.value;
var newPassword = event.target.newPassword.value;
Accounts.changePassword(oldPassword, newPassword)
}
I'm particularly confused because I've successfully used both Accounts.createUser() and Accounts.setPassword() in other methods.
On the server you should use
Accounts.setPasswordwhich you can use with the currentuserIdfrom the method invocation:See: https://docs.meteor.com/api/passwords.html#Accounts-setPassword