lundi 27 juin 2016

Trouble transitioning to current user after signing in with Emberfire

I am using Emberfire for my authentication and database and I am able to sign in, but it does not redirect me to my current users page after that. It also throws an error at me saying that no user exists at the custom url but my firebase console shows the user with the correct id that I am redirecting to.

Here is my login controller:

import Ember from 'ember';

export default Ember.Route.extend({
  beforeModel: function() {
    return this.get('session').fetch().catch(function() {});
  },
  actions: {
    signIn: function() {
      var controller = this.get('controller');
      var email = controller.get('email');
      var password = controller.get('password');
      this.get('session').open('firebase', { provider: 'password', 'email': email, 'password': password}).then(function(data) {
        console.log(data.currentUser);
      });
      let uid = this.get('session').get('uid');
      this.store.findRecord('user', uid).then(user => {
      console.log(user.get('firstName'));
      this.transitionTo('user', uid);
});
    },
    signOut: function() {
      this.get('session').close();
    }
  }
});

Here is my router:

Router.map(function() {
  this.route('signup');
  this.route('home', { path: '/' });
  this.route('login');
  this.route('user', { path: '/user/:user_id' });
});




Aucun commentaire:

Enregistrer un commentaire