Config Accounts.createUser to have only one email


#1

Again Im coming here for help since the docs cant help me.
Basically I want the option when a user creates the account(using accounts-password package) that Meteor.user() looks more like this:

{ _id: ..., email: ...., verified:....}

Now it creates this:

  { _id: ..., emails: [adress:..., verified:...] }

So why do I need this, since I dont plan on giving users the option to register more then one email address and I want to use it in my template with {{currentUser.email}} to display the email instead of the log in button after they register.

If there isn’t a easy way to config I have to use some functions to return the address value from the emails array which is a much bigger pain then just using {{currentUser.email}} and honestly not sure why the 1st isn’t the default since I assume the majority would only need/allow only one email per account and then if people need more emails they just set in the config emails:true or something.


#2

And as I type this I realize I can just set username to email and display it that way, but my questions still stands about it being the default option…


#3

Meteor will be easier to learn and to use if this isn’t configurable, and in the question of supporting one or multiple emails, multiple seems like the better choice.

In your case, I would add a transform to the Meteor.user to attach a function that just returns the first email. For example:

Meteor.users._transform = function(user) { 
    user.getEmail = function(){
        return this.emails[0]
    }
    return user
} 

Then you can use {{currentUser.getEmail.adress}} in Spacebars.