Diogenes
Diogenes

Reputation: 2747

What is the best way to update a users email address in meteor?

So the built in meteor auth system stores user emails under the user like so:

emails: [ { address: [email protected], verified: true} ]

Is there a 'meteoric' way to set a primary email, and update an email address (or add/remove emails)?

It seems to me if would be a great deal simpler if they were stored like so:

emails: { '[email protected]': { verified: true } }

Upvotes: 2

Views: 188

Answers (1)

Rahul
Rahul

Reputation: 12231

Your suggested object format makes no sense, because then how do I request that object? Normally I'd say obj.emails[i].address, now I have to say... what? for (var key in obj.emails) { var email = obj.emails[key]; }? That's much more complicated.

To update an email address, you should change the email address in the user record, mark it unverified, and initiate the verification process with Account.sendVerificationEmail.

Upvotes: 1

Related Questions