I am attempting to create a user via the Firebase Email & Password Authentication method and then creating an account with that newly created users id rather than using the automatically generated id. I am using my 'account' model to add accounts with Ember's 'store.createRecord' method to my Firebase backend. If anyone could help me make this work I would really appreciate it!
App.SignUpController = Ember.Controller.extend({
needs: ['sign-in'],
needs: ['application'],
userSignedIn: false,
actions: {
signMeUp: function() {
controllerContext = this;
var state = false;
// Create firebase user
ref.createUser({
email : this.get('email'),
password : this.get('password'),
}, function(error) {
if (error === null) {
console.log("User created successfully");
console.log("Authenticated successfully with payload:", authData);
state = true;
controllerContext.set('userSignedIn', state);
console.log("State from sign-up page: "+ state);
} else {
console.log("Error creating account:", error);
}
});
// Option 1: randomly generated id
var newAccount = this.store.createRecord('account', {
email: this.get('email'),
password: this.get('password'),
});
newAccount.save();
// Option 2: attempt to use id from createUser
ref.child("users").child(authData.uid).set(authData);
this.transitionToRoute('new-post');
}
}
});
Aucun commentaire:
Enregistrer un commentaire