私はセッション用の鳥居で EmberFire を使用しています。ユーザーをログアウトすると奇妙な問題が発生し、コンソールに次のエラーがスローされます。
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.
ユーザーをログインさせる場所は 2 つあります。
登録時
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');
});
}
すでに登録済みのユーザーの場合
login(email, password) {
const controller = this.controllerFor('index');
this.get('session').open('firebase', {
provider: 'password',
email: email,
password: password
})
.then((/* response */) => {
controller.set('loginError', undefined);
this.replaceWith('dashboard');
})
.catch((error) => {
controller.set('loginError', error);
});
}
そして、ユーザーをログアウトするアクションは次のとおりです。
logout() {
this.get('session').close().then(() => {
this.store.unloadAll();
this.replaceWith('index');
});
}