鳥居で ember-simple-auth を使用する方法について少し混乱しています
私は 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);
app/initializers/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);
}
});
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>