与火力地堡注销 [英] Logout with Firebase

查看:209
本文介绍了与火力地堡注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个用户验证,我在注销的一部分了。

I am trying to do a user auth, and I am in the part of the logout now

      <button ng-click="logOut(user)">
        GOING OUT
      </button>

下面是他们如何登录

  $scope.signIn = function (user) {
    $scope.signInErrorShow = false;
    if (user && user.email && user.pwdForLogin) {
      auth.$authWithPassword({
        email: user.email,
        password: user.pwdForLogin
      }).then(function (authData) {
        console.log("Logged in as:" + authData.password.email);
        ref.child("users").child(authData.uid).once('value', function (snapshot) {
          var val = snapshot.val();
          $scope.$apply(function () {
            $rootScope.displayName = val;
          });
        });
        $scope.userLogin = true;
        $ionicLoading.hide();
        $scope.closeModal();
        $rootScope.$broadcast('');
      }).catch(function (error) {
        $ionicLoading.hide();
      });
    } else
    $scope.signInErrorShow = true;
  };

和我试图打电话注销

  $scope.logOut = function(user) {
    ref.unauth();
  };

有一次我打电话注销,我没有看到任何职位或在浏览器的网络部分得到的。

once I call log out, I don't see any post or get in the Network section of the browser.

在火力地堡文档,所有他们说的退出是这样

In the Firebase Docs, all they say about log out is this

记录用户退出

调用UNAUTH()无效用户的令牌,并记录他们出您的应用程序:

Calling unauth() invalidates the user's token and logs them out of your application:

复制
  ref.unauth();
  如果你有previously使用的onAuth()方法来监听验证状态,你的回调现在将使用空了的authData调用。

Copy ref.unauth(); If you had previously used the onAuth() method to listen for authentication state, your callback would now be invoked with null for authData.

所以我应该怎么办吗?

推荐答案

关于注销未显示任何网络活动:在登录火力点可能给你一个访问令牌(由火力客户端脚本保存)当您登录

Concerning logout not showing any network activity: on login firebase probably gives you an access token (kept by the firebase client script) when you login.

在登录后您的应用程序访问火力它会将此令牌您请求的报头(授权头?)。

When after login your application accesses firebase it adds this token to the header of your requests (authorization header?).

在注销时火力客户端脚本简单地擦除标记。这种方式的火力后端不必保持会话状态在其(分布式)服务器。他们只需要检查每个请求发送令牌的有效性。

When you logoff the firebase client script simply erases the token. This way the firebase backend doesn't have to keep session state on their (distributed) servers. They only have to check the validity of the token sent in each request.

这篇关于与火力地堡注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆