I created a webpage where the users can update their data (email, fullname, password). It calls this meteor method on the server:
'users.updateCurrentUser'(doc) {
if (!this.userId) {
throw new Meteor.Error('not-authorized', 'you must be a logged in!');
}
check(doc.email, String),
check(doc.profile.fullname, String),
check(doc.password, String);
const isSuccess = Users.update(this.userId, {
$set: {
'emails.0.address': doc.email,
profile: doc.profile
}
});
Accounts.setPassword(this.userId, doc.password);
if (isSuccess) {
console.log(`User with id: ${this.userId} was updated`);
} else {
throw new Meteor.Error('unsuccessful-update', `User with id: ${this.userId} couldn't be updated`);
}
}
The update works but my problem is that everytime the user does this update then they’ll get logged out. Is there a way to prevent this?