我正在尝试让用户注册使用 Firebase 作为后端在我的 ember 应用程序上工作。我正在使用 torii 附加组件进行用户身份验证,并且只是在尝试对其进行测试。但是,当我尝试注册用户时,出现以下错误:Uncaught TypeError: n.default is not a constructor
这就是我的路线的样子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("https://my-app-name.firebaseio.com");
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');
});
});
}
});
}
}
});
我的模板在templates/index.hbs:
Signup here: <br>
{{input type="text" value=firstName placeholder="First Name"}}<br>
{{input type="text" value=lastName placeholder="Last Name"}}<br>
{{input type="text" value=email placeholder="Email"}}<br>
{{input type="password" value=password placeholder="Password"}}<br>
<button {{action "signUp"}}> Sign Up </button>
和我的用户模型:
import DS from 'ember-data';
export default DS.Model.extend({
firstName: DS.attr(),
lastName: DS.attr()
});
我真的不确定我要去哪里错了。我几乎遵循了本指南: http: //vikram-s-narayan.github.io/blog/authentication-with-ember-and-firebase-part-2/,除了我只专注于注册并为简单起见将其全部放入索引中。