How to update the user's verified email after social facebook login


#1

Hi,

I’ve been using Meteor for a couple months and it has grown on me a lot, Aldeed Collections and Yogi Admin seem good enough to be in the core… but that topics for another day.

I’m trying to update my emails array schema after success account create and here’s what I get:

  emails:
    type: [Object]
    optional: true

  "emails.$.address":
    type: String
    regEx: SimpleSchema.RegEx.Email

  "emails.$.verified":
    type: Boolean


Accounts.onCreateUser (options,user) ->
  username = null
  parseInstagram = (options) ->
    console.log  'parseInstagram', options, user
    o = {}
    if options?.services?.instagram
      o.profilePicture = options.services.instagram.profile_picture
      o.fullName = options.services.instagram.full_name
      o.bio =  options.services.instagram.bio
    o

  parseFb = (user) ->
    console.log  'parseFb', user
    o = {}
    if user?.services?.facebook
      getFbProfile = (accessToken) ->
        result = undefined
        url = "https://graph.facebook.com/me?fields=age_range,birthday,about,email,bio,address&access_token=#{accessToken}"
        result = Meteor.http.get(url)
        result?.data
      data = getFbProfile( user?.services?.facebook?.accessToken )
      o.fullName = user?.services?.facebook?.name
      o.emails = [{ address: data?.email, verified: true }] if data?.email
      o.profilePicture = "http://graph.facebook.com/" + user?.services?.facebook.id + "/picture/?type=large"
      o
    else undefined

No email seems to go in, while other fields go in happily.
Thanks for your help before I hack this with a _.defer function to update the user after the facet.


#2

Sorry, i just had to set it on the user object… i didn’t realize that. It was a simple fix.