[英]Firebase 3 Authentication with Emberfire and Torii
I'm trying to authenticate with Firebase's email/password provider, but keep getting the following error: 我正在尝试通过Firebase的电子邮件/密码提供程序进行身份验证,但始终收到以下错误消息:
Uncaught TypeError: Cannot read property 'open' of undefined
未捕获的TypeError:无法读取未定义的属性“ open”
Here's what my app looks like: 这是我的应用程序的外观:
app/torii-adapters/applications.js 应用程序/鸟居的适配器/ applications.js
import Ember from 'ember';
import ToriiFirebaseAdapter from 'emberfire/torii-adapters/firebase';
export default ToriiFirebaseAdapter.extend({
firebase: Ember.inject.service()
});
app/adapters/application.js 应用程序/适配器/ application.js中
import Ember from 'ember';
import FirebaseAdapter from 'emberfire/adapters/firebase';
const { inject } = Ember;
export default FirebaseAdapter.extend({
firebase: inject.service()
});
app/templates/components/login-cmp.hbs 应用程序/模板/组件/登录,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>
app/components/login-cmp.js 应用/组件/登录-cmp.js
signIn: function(email, password) {
this.get('session').open('firebase', { provider: 'password', email: email, password: password}).then(function(data) {
console.log(data.currentUser);
});
},
Using the same config/environment.js setup shown on https://github.com/firebase/emberfire with my firebase projects domains and key. 将https://github.com/firebase/emberfire上显示的config / environment.js设置与我的Firebase项目域和密钥一起使用。 Also have
也有
torii: {
sessionServiceName: 'session'
},
I also have the email/password provider Enabled on my firebase account. 我的firebase帐户也启用了电子邮件/密码提供程序。
Not sure where the disconnect is. 不知道断开的位置。 Any help is much appreciated.
任何帮助深表感谢。 Thanks!
谢谢!
* Ember-CLI v2.11 * Emberfire v2.0.6 * Torii v0.8.1 * Node v6.9.5 * Ember-CLI v2.11 * Emberfire v2.0.6 * Torii v0.8.1 *节点v6.9.5
The signIn action button does not tell your ember app what provider you are using, only the login credentials were provided, it should look like: 登录操作按钮不会告诉您的ember应用程序您在使用什么提供程序,仅提供了登录凭据,它应该类似于:
{{action 'signIn' "password" email password}}
and finally your signIn action code should look like: 最后,您的登录操作代码应如下所示:
signIn() {
let controller = this;
this.get('session').open('firebase', { provider: 'password', email: this.get('email') || '', password: this.get('password') || ''}).then(function(data) {
console.log(data.currentUser);
});
},
For anyone else getting this error, at this time Ember version 2.13.1 has an error with Emberfire and torii : internal "torii" instance is undefined
as the mechanism for getting owner or factory has been slightly changed in Ember 2.13, so "open" can not be called. 对于其他收到此错误的人,此时Ember版本2.13.1的Emberfire和torii出现错误 :内部“ torii ”实例
undefined
因为在Ember 2.13中获取所有者或工厂的机制已稍作更改,因此“打开”不能叫。 So far the latest working version is 2.12.0 . 到目前为止, 最新的工作版本是2.12.0 。
More info: https://github.com/firebase/emberfire/issues/503 更多信息: https : //github.com/firebase/emberfire/issues/503
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.