Using Torii - session service doesn't inject into routes/controllers
See original GitHub issueHave pored over several tutorials for an EmberFire / Torii setup and am not able to get the session
service to work at all. Is a step missing or is there possibly an issue with newer versions of EmberJS when injecting the session service?
environment.js
module.exports = function(environment) {
var ENV = {
...
firebase: {
apiKey: '',
authDomain: '',
databaseURL: '',
storageBucket: ''
},
torii: { sessionServiceName: 'session' },
...
};
}
app/torii-adapters/application.js
import Ember from 'ember';
import ToriiFirebaseAdapter from 'emberfire/torii-adapters/firebase';
export default ToriiFirebaseAdapter.extend({
firebase: Ember.inject.service()
});
routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function() {
return this.get("session").fetch().catch(function() {});
},
...
}
Browser console when visiting application route:
ember.debug.js:28058Error while processing route: index Cannot read property 'fetch' of undefined TypeError: Cannot read property 'fetch' of undefined
Guides consulted while trying to sort this out: http://www.programwitherik.com/emberjs_2-0_example_app_with_firebase/ http://www.danielgynn.com/third-party-auth-in-ember-with-firebase/
Package versions - “ember-cli”: “2.3.0”, “emberfire”: “2.0.1”, “ember”: “~2.3.1”, “firebase”: “^3.0.0”
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Torii Session Service does not inject into routes/controllers #312
I npm install'd torii and it worked after that. Something is wrong with the bower side. All reactions.
Read more >Torii Not injecting 'session' EmberJS 2.0 - Stack Overflow
I solved the issue by explicitly install torii via npm: npm install torii. Restarted the server and all is well. Share. Share a...
Read more >Introducing Torii: Authentication primitives for Ember apps
Now controllers and routes have a session injection. Sessions respond to open , fetch , and close with promises. If open or fetch...
Read more >torii - npm Package Health Analysis - Snyk
Torii can perform session management via the session service, injected onto routes and controllers. You can activate session management by specifying ...
Read more >ember-simple-auth
Once the library is installed, the session service can be injected wherever needed in the application. In order to display login/logout ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I found the issue. I had installed
ember-simple-auth
, which is no longer needed and causes this to break. Removing this npm package allowed everything to work as expected.I tried doing this with explicitly injecting the session, to which it complained there was no such service.
Also all examples of how to use Torii I found imply that session is already implicitly injected. Please see: https://www.danielgynn.com/third-party-auth-in-ember-with-firebase/