【问题标题】:Permission error on auth logout: firebase/ionic/angularfire2身份验证注销时的权限错误:firebase/ionic/angularfire2
【发布时间】:2017-10-09 20:46:19
【问题描述】:

我有一个使用 angularfire2 和 firebase 的 ionic3 应用程序。我使用 firbase auth 登录到我的应用程序,并从 firebase 检索有关“currentChallenges”的对象。当我使用注销功能时,Firebase 会引发错误。

错误信息:

permission_denied at /currentChallenge:客户端没有权限 访问所需的数据。

我在 auth.service.ts 中使用以下函数进行注销:

logout() {
    this.isLoggedIn = false;
    this.firebaseAuth
        .auth
        .signOut().then(() => {
            this.appCtrl.getRootNav().popToRoot(); //root is login page
        });
}

我不确定到底是哪里/是什么导致了错误。在我的challenge.service.ts 中,我制作了初始可观察对象:

private dbCurrentChallengesObservable: FirebaseObjectObservable <any>;
 
constructor(db: AngularFireDatabase) { 
  this.dbCurrentChallengesObservable = db.object('/currentChallenge');  
}

public getCurrentChallenges(){
  return this.dbCurrentChallengesObservable;
}

然后,我在我的模型 (challenges.ts) 中使用这个对象,如下所示:

ionViewCanEnter(): boolean{
    return this.authService.isAuthenticated();
}
   
ionViewDidLoad() {
    this.currentChallenge = this.challengesService.getCurrentChallenges();
    this.currentChallenge.subscribe(data => {
        if(data.challenge1completed > 0) this.challenge1Completed = true;
        if(data.challenge2completed > 0) this.challenge2Completed = true;
    });
}

起初我以为它与订阅有关,我在 Challenges.ts 的 on-ion-leave 函数中添加了一个 subscribe().unsubscribe(),但这并没有阻止错误。但是某些东西必须仍然在听firebase,必须在注销时甚至注销之前停止。我只是不知道什么/在哪里/如何。

任何帮助将不胜感激。

【问题讨论】:

    标签: firebase firebase-authentication ionic3 angularfire2


    【解决方案1】:
    private afDatabase: AngularFireDatabase,//blabla       
    this.afDatabase.database.goOffline();//To solve the permission denied 문제.
    

    在signout()之前添加上述语句;

    我在这个问题上也花了很多时间,但没有找到任何线索。 希望这会有所帮助

    【讨论】:

      猜你喜欢
      • 2016-11-14
      • 2017-02-13
      • 2014-07-19
      • 1970-01-01
      • 1970-01-01
      • 2016-10-30
      • 2021-05-24
      • 2017-07-30
      • 1970-01-01
      相关资源
      最近更新 更多