mardi 28 juin 2016

Closing an emberfire/torii session and logging out throws permission_denied errors

I am using EmberFire with the Torii for sessions. I am getting an odd issue when I log a user out, and the following errors are thrown in the console:

firebase.js:186 Error: permission_denied at /folders/-KKvrk3K_JOHxQWgR1km: Client doesn't have permission to access the desired data.(…)(anonymous function) @ firebase.js:186(anonymous function) @ firebase.js:380Tb @ firebase.js:276uc @ firebase.js:263vc @ firebase.js:262(anonymous function) @ firebase.js:449vh @ firebase.js:434g.wd @ firebase.js:425Ye.wd @ firebase.js:328(anonymous function) @ firebase.js:326vd @ firebase.js:279La.onmessage @ firebase.js:278
firebase.js:186 Error: permission_denied at /folders/-KLFp3zh5QUB7KvMF0HZ: Client doesn't have permission to access the desired data.(…)(anonymous function) @ firebase.js:186(anonymous function) @ firebase.js:380Tb @ firebase.js:276uc @ firebase.js:263vc @ firebase.js:262(anonymous function) @ firebase.js:449vh @ firebase.js:434g.wd @ firebase.js:425Ye.wd @ firebase.js:328(anonymous function) @ firebase.js:326vd @ firebase.js:279La.onmessage @ firebase.js:278
firebase.js:186 Error: permission_denied at /externalApps/-KLF_wKXtzm38EHtuQ_C: Client doesn't have permission to access the desired data.(…)(anonymous function) @ firebase.js:186(anonymous function) @ firebase.js:380Tb @ firebase.js:276uc @ firebase.js:263vc @ firebase.js:262(anonymous function) @ firebase.js:449vh @ firebase.js:434g.wd @ firebase.js:425Ye.wd @ firebase.js:328(anonymous function) @ firebase.js:326vd @ firebase.js:279La.onmessage @ firebase.js:278
firebase.js:186 Error: permission_denied at /users/-KLKUOZRBCIeCj44WMe7: Client doesn't have permission to access the desired data.(…)(anonymous function) @ firebase.js:186(anonymous function) @ firebase.js:380Tb @ firebase.js:276uc @ firebase.js:263vc @ firebase.js:262(anonymous function) @ firebase.js:449vh @ firebase.js:434g.wd @ firebase.js:425Ye.wd @ firebase.js:328(anonymous function) @ firebase.js:326vd @ firebase.js:279La.onmessage @ firebase.js:278
firebase.js:186 Error: permission_denied at /externalApps/-KLIyXUwTSrkCIL4rz7U: Client doesn't have permission to access the desired data.

This only seems to happen when I log the user in immediately after registering them. Here is the code that registers and logs in the user:

register(data) {
  return this.get('firebaseApp')
    .auth()
    .createUserWithEmailAndPassword(data.email, data.password)
    .then((registeredUser) => {
      const newUser = this.store.createRecord('user', {
        uid: registeredUser.uid,
        firstName: data.firstName,
        lastName: data.lastName,
        email: registeredUser.email
      })
      return newUser.save();
    })
    .then((savedUser) => {
      return this.get('session').fetch().then(() => {
        return savedUser;
      });
    })
    .then((savedUser) => {
      this.replaceWith('dashboard');
    });
}

And here is the action that logs the user out:

logout() {
  this.get('session').close().then(() => {
    this.store.unloadAll();
    this.replaceWith('index');
  });
}




Aucun commentaire:

Enregistrer un commentaire