Ionic / Firebase:退出登录后无法正常工作

时间:2016-02-04 14:37:49

标签: ionic-framework firebase angularfire firebase-authentication ionic-view

我正在使用Ionic/Phonegap后端构建Firebase应用。

登录

按照official AngularFire documentation中的示例进行登录:

// Check sign-in data
$scope.signIn = function(user, password) {

    // Log in
    $scope.auth.$authWithPassword({
        email    : user,
        password : password
    })

    // If successful
    .then(function(authData) {
        console.log('worked');
        // Further code
    }

    // If failure, alert
    .catch(function(error) {

        console.log(error);
    }
}

登录正常。

注销

对于注销,我还复制了文档中的示例:

$scope.logout = function() {

    // Manually disconnect from database
    Firebase.goOffline();

    // Log user out
    $scope.auth.$unauth();

    // Go to landing page
    $state.go('signin');
};

似乎也可以工作(当我在注销$ getAuth()后请求用户的当前身份验证状态时返回null)。

退出后登录

但如果我现在尝试再次登录,则不会发生任何事情 - 没有错误,没有成功消息。所以console.logs都没有触发。

我需要再次关闭并打开应用程序或刷新浏览器窗口才能再次登录。谁能告诉我我在这里做错了什么?

版本

使用最新版本:

Ionic 1.2.4

Firebase 2.4.0

AngularFire 1.1.3

1 个答案:

答案 0 :(得分:4)

从您的退出中删除Firebase.goOffline()。如果您想手动管理Firebase连接,则应考虑在登录期间添加Firebase.goOnline()

验证。$ unauth()将负责注销用户,您无需手动断开Firebase。