Can I copy third party login emails to the root emails key in user document?

Hi,

I have a multi-user app, which depends on the user having a unique username or email.

I am planning on using Google as a third party login.

I’ve tested it and I notice when I login with google account the email is available under the services key, but no email key or username key exists.

So what I have done is in the Accounts.onCreateUser function I extract the email address and manually create the emails key with address and verified keys like a user would have if they normally signed up.

Like this

Accounts.onCreateUser (options,user) ->

  unless user.emails?
    
    emailData = 
      address: determineEmail(user) * this gets [user.services.google.email]
      verified: false

    user.emails = []
    user.emails.push emailData

  if options.profile?
    if options.profile.name?
      nameArr = options.profile.name.split(" ")
      firstName = nameArr[0]
      lastName = nameArr[1]

      options.profile.firstName = firstName
      options.profile.lastName = lastName
    
    user.profile = options.profile

  user

So I am extracting the email from google services and make it so the email is available at Meteor.user().emails[0].address

This is because I use Meteor.user().emails[0].address throughout my app.

Will this cause any issues though? It seems to be working fine however I test it.