This is my first time using ember.js. I'm trying to use a controller to execute an action when a user is successfully signed in (authenticated). However, my current method of saving the user's state or even changing a property 'this.set('userSignedIn', state);' is not working. I'm not exactly sure why, I'm guessing it has to do with the scope of my 'state' variable or perhaps the 'this' object is not being passed to 'ref.authWithOAuthPopup()'. I'm hoping someone can point in the right direction.
var ref = new Firebase("http://ift.tt/1JdLgDn");
var state = false;
MyApp.ApplicationController = Ember.Controller.extend({
actions: {
userSignedIn: false,
signin: function() {
ref.authWithOAuthPopup("facebook", function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
state = true;
}
});
this.set('userSignedIn', state);
console.log(state);
}, // End of signin
}
});
Aucun commentaire:
Enregistrer un commentaire