lundi 17 avril 2017

Custom session data not persisting in ember-fire

I am trying to add the custom session variable session.currentUser.isBusiness in ember-fire. However, on page reload, the data does not persist and disappears.

I'm putting the login logic within my login route, which looks like this:

import Ember from ‘ember’;

export default Ember.Component.extend({
 classNames: [‘login-form’],
    router: Ember.inject.service(‘-routing’),
   actions: {
   signIn(provider) {
     let controller = this;
     this.get(‘session’).open(‘firebase’, {
       provider: provider,
       email: this.get(‘email’) || ‘’,
       password: this.get(‘password’) || ‘’,
     }).then(() => {
       this.get(‘session’).set(‘currentUser.isBusiness’, true );

       controller.get(‘router’).transitionTo(‘business.portal’);
     }, (error) => {
       alert(error);
     });
   },
   googleSignIn(){
     let controller=this;
           this.get(‘session’).open(‘firebase’, { provider: ‘google’}).then(function(data) {
             data = null;
           controller.transitionToRoute(‘portal’);
           }, (error) => {
       alert(error);
     });
   }
 }
});

It works when I first sign in and I can see that session.currentUser.isBusiness is set to false; however, when the page is reloaded, session.currentUser.isBusiness no longer exists.

I'm using Ember 2.11 and the latest version of ember-fire.

What should I change to make sure the data persists?




Aucun commentaire:

Enregistrer un commentaire