我对如何使用带有torii的ember-simple-auth感到困惑
我正在使用ember-cli-simple-auth和ember-cli-simple-auth-torii
我得到下面提到的错误
不知道我失踪了
Uncaught Error: Assertion Failed: No application initializer named 'torii'
routes.js
Router.map(function() {
this.route('login');
this.route('application');
this.route('protected');
});
应用程序/路由/ application.js中
import Ember from 'ember';
import ApplicatonRouteMixin from 'simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(ApplicatonRouteMixin);
应用程序/路线/登录
import Ember from 'ember';
export
default Ember.Route.extend({
actions: {
// action to trigger authentication with Facebook
authenticateWithFacebook: function () {
this.get('session').authenticate('simple-auth-authenticator:torii', 'facebook-oauth2');
}
}
});
应用程序/路由/受保护的
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend( AuthenticatedRouteMixin);
应用程序/初始化/牌坊-initializer.js
import ToriiAuthenticator from 'simple-auth-torii/authenticators/torii';
export default Ember.Application.initializer({
name: 'authentication',
initialize: function(container, application) {
// register the Torii authenticator so the session can find them
container.register('simple-auth-authenticator:torii', ToriiAuthenticator);
Ember.SimpleAuth.setup(container, application);
}
});
的index.html
window.AuthENV = {
{
ENV
}
};
window.EmberENV = window.AuthENV.EmberENV;
window.ENV = window.ENV || {};
window.ENV['torii'] = {
providers: {
'facebook-oauth2': {
apiKey: '63125ss',
redirectUri: document.location.href
}
}
};
登录模板
<h1>Login</h1>
<a {{action "authenticateWithFacebook"}}> login</a>
答案 0 :(得分:3)
您需要安装torii Ember CLI Addon以及安装ember-cli-simple-auth-torii时当前未自动包含的内容:
npm install --save-dev torii