question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Torii - session service doesn't inject into routes/controllers

See original GitHub issue

Have 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
erichigginscommented, Jan 17, 2017

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.

3reactions
thedigcommented, Oct 4, 2016

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/

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found