3
votes

I keep receiving the error that the session var is not defined. I've looked at other answers on here about restarting ember serve to remove any caching issues but I've tried that multiple times and I've followed the emberfire guide to the letter. Does anyone have any idea what could be going wrong? The authentication succeeds but the session doesn't get bound to. Here are my files:

/app/routes/application.js

import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    return this.store.query('post', {
      orderBy: 'timestamp',
      limitToLast: 3
    });
  },
  actions: {
    authenticate: function(username, pass) {
      this.get('session').open('firebase', {
        provider: "password",
        email: username,
        password: pass
      }).then(function (data) {
        console.log(data.currentUser);
        console.log(session);
      });
    }
  }
});

/app/torii-adapters

import Ember from 'ember';
import ToriiFirebaseAdapter from 'emberfire/torii-adapters/firebase';

export default ToriiFirebaseAdapter.extend({
  firebase: Ember.inject.service()
});

/config/environment.js

var ENV = {
    modulePrefix: 'website',
    environment: environment,
    contentSecurityPolicy: { 'connect-src': "'self' https://auth.firebase.com wss://*.firebaseio.com" },
    firebase: 'https://REMOVED.firebaseio.com/',
    torii: {
      sessionServiceName: 'session'
    },
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };
1
I've run into a similar issue using a custom Torii adapter. Can anyone out there confirm that Torii v 0.5.1 is Ember 2.0.2 compatible? Thanks! - Mayank Patel
I'm not sure what I did, but it started working after a bunch of messing around, then cleaning out my repot (including reinstalling node packages and bower packages), restarting the ember server, etc. I am not adding the "torii-adapter", and I have torii installed via npm, not via bower. I just have the package.json, as well as the application.js, and environment.js entries you have here. I am also including the appropriate actions in an hbs template. Really, nothing much different than your code. - Merlyn Morgan-Graham
The torii docs do claim you don't have to do anything special or use that adapter if you are using ember-cli, and install it via npm. Maybe this is a difference for you from my project - though I did have the same problems as you for a while before I messed around, cleaned and reinstalled my repot, and restarted my server. - Merlyn Morgan-Graham

1 Answers

1
votes

I was having the same issue following the tutorial for emberfire. I solved the issue by explicitly install torii via npm:

npm install torii

Restarted the server and all is well.