I have a form that the user can input to change their username. Upon submit, I want to update their username.
I initially tried this:
'submit .editProfileForm': function(event) {
event.preventDefault();
var newUsername = event.target.newUsernameInput.value;
//update users username.
Meteor.users.update(Meteor.userId, {
$set: {
username: newUsername
}
});
}
But was getting a generic Access denied in the console. I then saw that using Accounts.setUsername()
was recommended, so I tried the following:
'submit .editProfileForm': function(event) {
event.preventDefault();
var newUsername = event.target.newUsernameInput.value;
//update users username.
Accounts.setUsername(Meteor.userId(), newUsername)
}
This instead gave me a TypeError:
TypeError: Accounts.setUsername is not a function
So what is the proper way to do this? I know the users
Collection is a “special” Collection so i’m not sure if theres some other steps needed.