jeudi 25 août 2016

ember.js and firebase - unable to sign up user

I'm trying to get a user sign up working on my ember app using firebase as the backend. I'm using the torii add-on for user authentication and am just trying to test it out. However when I try to sign up a user I get the following error: Uncaught TypeError: n.default is not a constructor

This is how my route looks at routes/index.js:

import Ember from 'ember';
import Firebase from 'firebase';

export default Ember.Route.extend({
  actions: {
    signUp: function(){
      var controller = this.get('controller');
      var firstName = controller.get('firstName');
      var lastName = controller.get('lastName');
      var email = controller.get('email');
      var password = controller.get('password');
      var ref = new Firebase("http://ift.tt/29z2EHE");
      var _this = this;

    ref.createUser({
      email    : email,
      password : password
      }, 
      function(error, userData){
        if (error) {
          alert(error);
        } else {
          _this.get('session').open('firebase', {
            provider: 'password',
            'email': email,
            'password': password
          }).then(function(){
            var user = _this.store.createRecord('user', {
              id: userData.uid,
              firstName: firstName,
              lastName: lastName
            });

            user.save().then(function(){
              _this.transitionTo('protected');
            });
          });
        }
      });
    }
  }
});

My template at templates/index.hbs:

Signup here: <br>

<br>
<br>
<br>
<br>
<button > Sign Up </button>

and my user model:

import DS from 'ember-data';

export default DS.Model.extend({
  firstName: DS.attr(),
  lastName: DS.attr()
});

I'm really not sure where I'm going wrong. I've pretty much followed this guide: http://ift.tt/2bl6PsX, except I'm just focusing on the sign up and putting it all in the index for simplicity.




Aucun commentaire:

Enregistrer un commentaire