Last active
August 29, 2015 13:56
-
-
Save endash/9183330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook: function () { | |
var route = this; | |
FB.login(function (response) { | |
if (response.authResponse) { | |
var session = route.controllerFor('session'); | |
session.set('facebookAccessToken', response.authResponse.accessToken) | |
session.save().then(function () { | |
route.transitionTo('calendar_month') | |
}); | |
} | |
}); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SessionController = Ember.ObjectController.extend({ | |
needs: ['user', 'account', 'accountUser'], | |
end: function () { | |
var controller = this; | |
var old = this.get('content'); | |
this.set('content', controller.store.createRecord('session')); | |
return old.destroyRecord().then(function () { | |
localStorage.setItem('accessToken', ""); | |
}); | |
}, | |
save: function () { | |
var controller = this; | |
return this.get('content').save().then(function (session) { | |
localStorage.setItem('accessToken', session.get('accessToken')); | |
localStorage.setItem('currentAccountUser', session.get('user.accountUsers.firstObject.id')); | |
controller.set('controllers.accountUser.content', session.get('user.accountUsers.firstObject')); | |
}, function (e) { | |
localStorage.setItem('accessToken', ""); | |
localStorage.setItem('currentAccountUser', ""); | |
throw e; | |
}); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Session = DS.Model.extend({ | |
facebookAccessToken: DS.attr(), | |
accessToken: DS.attr(), | |
user: DS.belongsTo('user') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment