ember.js - Ember-cli-simple auth and ember-cli-simple-auth-torii how to make them work together -
i little confused on how use ember-simple-auth torii
i using ember-cli-simple-auth , ember-cli-simple-auth-torii getting below mentioned error dont know waht missing uncaught error: assertion failed: no application initializer named 'torii'
routes.js
router.map(function() { this.route('login'); this.route('application'); this.route('protected'); }); app/routes/application.js
import ember 'ember'; import applicatonroutemixin 'simple-auth/mixins/application-route-mixin'; export default ember.route.extend(applicatonroutemixin); app/route/login
import ember 'ember'; export default ember.route.extend({ actions: { // action trigger authentication facebook authenticatewithfacebook: function () { this.get('session').authenticate('simple-auth-authenticator:torii', 'facebook-oauth2'); } } }); app/routes/protected
import ember 'ember'; import authenticatedroutemixin 'simple-auth/mixins/authenticated-route-mixin'; export default ember.route.extend( authenticatedroutemixin); app/initializers/torii-initializer.js
import toriiauthenticator 'simple-auth-torii/authenticators/torii'; export default ember.application.initializer({ name: 'authentication', initialize: function(container, application) { // register torii authenticator 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 } } }; login template
<h1>login</h1> <a {{action "authenticatewithfacebook"}}> login</a>
you need install torii ember cli addon that's not automatically included when install ember-cli-simple-auth-torii:
npm install --save-dev torii
Comments
Post a Comment