Fixed logging in with facebook and google plus to not overwrite existing user settings.

This commit is contained in:
Scott Erickson 2014-01-08 14:57:42 -08:00
parent 70cd16cee4
commit aab11ea5f7
2 changed files with 16 additions and 7 deletions

View file

@ -42,16 +42,20 @@ module.exports = FacebookHandler = class FacebookHandler extends CocoClass
return
oldEmail = me.get('email')
me.set('firstName', r.first_name) if r.first_name
me.set('lastName', r.last_name) if r.last_name
me.set('gender', r.gender) if r.gender
me.set('email', r.email) if r.email
me.set('facebookID', r.id) if r.id
patch = {}
patch.firstName = r.first_name if r.first_name
patch.lastName = r.last_name if r.last_name
patch.gender = r.gender if r.gender
patch.email = r.email if r.email
patch.facebookID = r.id if r.id
me.set(patch)
patch._id = me.id
Backbone.Mediator.publish('logging-in-with-facebook')
window.tracker?.trackEvent 'Facebook Login'
window.tracker?.identify()
me.save({}, {
me.save(patch, {
patch: true
error: backboneFailure,
url: "/db/user?facebookID=#{r.id}&facebookAccessToken=#{@authResponse.accessToken}"
success: (model) ->

View file

@ -64,7 +64,12 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
gplusID = me.get('gplusID')
window.tracker?.trackEvent 'Google Login'
window.tracker?.identify()
me.save({}, {
patch = {}
patch[key] = me.get(key) for gplusKey, key of userPropsToSave
patch._id = me.id
patch.email = me.get('email')
me.save(patch, {
patch: true
error: backboneFailure,
url: "/db/user?gplusID=#{gplusID}&gplusAccessToken=#{@accessToken}"
success: (model) ->