mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 10:56:53 -05:00
Fixed logging in with facebook and google plus to not overwrite existing user settings.
This commit is contained in:
parent
70cd16cee4
commit
aab11ea5f7
2 changed files with 16 additions and 7 deletions
|
@ -42,16 +42,20 @@ module.exports = FacebookHandler = class FacebookHandler extends CocoClass
|
||||||
return
|
return
|
||||||
|
|
||||||
oldEmail = me.get('email')
|
oldEmail = me.get('email')
|
||||||
me.set('firstName', r.first_name) if r.first_name
|
patch = {}
|
||||||
me.set('lastName', r.last_name) if r.last_name
|
patch.firstName = r.first_name if r.first_name
|
||||||
me.set('gender', r.gender) if r.gender
|
patch.lastName = r.last_name if r.last_name
|
||||||
me.set('email', r.email) if r.email
|
patch.gender = r.gender if r.gender
|
||||||
me.set('facebookID', r.id) if r.id
|
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')
|
Backbone.Mediator.publish('logging-in-with-facebook')
|
||||||
window.tracker?.trackEvent 'Facebook Login'
|
window.tracker?.trackEvent 'Facebook Login'
|
||||||
window.tracker?.identify()
|
window.tracker?.identify()
|
||||||
me.save({}, {
|
me.save(patch, {
|
||||||
|
patch: true
|
||||||
error: backboneFailure,
|
error: backboneFailure,
|
||||||
url: "/db/user?facebookID=#{r.id}&facebookAccessToken=#{@authResponse.accessToken}"
|
url: "/db/user?facebookID=#{r.id}&facebookAccessToken=#{@authResponse.accessToken}"
|
||||||
success: (model) ->
|
success: (model) ->
|
||||||
|
|
|
@ -64,7 +64,12 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
|
||||||
gplusID = me.get('gplusID')
|
gplusID = me.get('gplusID')
|
||||||
window.tracker?.trackEvent 'Google Login'
|
window.tracker?.trackEvent 'Google Login'
|
||||||
window.tracker?.identify()
|
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,
|
error: backboneFailure,
|
||||||
url: "/db/user?gplusID=#{gplusID}&gplusAccessToken=#{@accessToken}"
|
url: "/db/user?gplusID=#{gplusID}&gplusAccessToken=#{@accessToken}"
|
||||||
success: (model) ->
|
success: (model) ->
|
||||||
|
|
Loading…
Reference in a new issue