我对如何将 ember-simple-auth 与 torii 一起使用有点困惑
我正在使用 ember-cli-simple-auth 和 ember-cli-simple-auth-torii 我得到下面提到的错误不知道我错过了什么
Uncaught Error: Assertion Failed: No application initializer named 'torii'
路由.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);
应用程序/初始化程序/torii-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);
}
});
索引.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>