我正在尝试通过 Firebase 的电子邮件/密码提供商进行身份验证,但不断收到以下错误:
未捕获的类型错误:无法读取未定义的属性“打开”
这是我的应用程序的样子:
应用程序/torii-适配器/applications.js
import Ember from 'ember';
import ToriiFirebaseAdapter from 'emberfire/torii-adapters/firebase';
export default ToriiFirebaseAdapter.extend({
firebase: Ember.inject.service()
});
应用程序/适配器/application.js
import Ember from 'ember';
import FirebaseAdapter from 'emberfire/adapters/firebase';
const { inject } = Ember;
export default FirebaseAdapter.extend({
firebase: inject.service()
});
应用程序/模板/组件/登录-cmp.hbs
...
<form class="col s12">
<div class="row">
<div class="input-field col s12">
{{input
id="userEmail"
type="email"
value=email
class="validate"
}}
<label for="email">Email</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
{{input
id="userPassword"
type="password"
value=password
class="validate"
}}
<label for="password">Password</label>
</div>
</div>
<div class="row">
<div class="col s12 m4">
<button class="btn waves-effect waves-light btn-large mt-20 mb-10" type="submit" {{action 'signIn' email password}}>Sign in
<i class="material-icons right">send</i>
</button>
</div>
</div>
</form>
应用程序/组件/登录-cmp.js
signIn: function(email, password) {
this.get('session').open('firebase', { provider: 'password', email: email, password: password}).then(function(data) {
console.log(data.currentUser);
});
},
将https://github.com/firebase/emberfire上显示的相同 config/environment.js 设置与我的 firebase 项目域和密钥一起使用。也有
torii: {
sessionServiceName: 'session'
},
我的 firebase 帐户上还启用了电子邮件/密码提供商。
不知道断线在哪里。任何帮助深表感谢。谢谢!
* Ember-CLI v2.11 * Emberfire v2.0.6 * Torii v0.8.1 * 节点 v6.9.5