加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 使用Firebase注销

发布时间:2020-12-17 17:14:35 所属栏目:安全 来源:网络整理
导读:我正在尝试进行用户身份验证,现在我正在注销 button ng-click="logOut(user)" GOING OUT /button 这是他们如何登录 $scope.signIn = function (user) { $scope.signInErrorShow = false; if (user user.email user.pwdForLogin) { auth.$authWithPassword({
我正在尝试进行用户身份验证,现在我正在注销

<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;
  };

而我正在尝试调用logOut

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

一旦我呼叫退出,我没有看到任何帖子或进入浏览器的网络部分.

在Firebase文档中,他们所说的注销就是这个

Logging Users Out

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

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.

那我该怎么办?

解决方法

关于注销没有显示任何网络活动:在登录时,firebase可能会在您登录时为您提供访问令牌(由firebase客户端脚本保留).

登录后,您的应用程序访问firebase,它会将此标记添加到您的请求标头(授权标头?).

注销firebase客户端脚本时,只需删除令牌即可.这样,firebase后端不必在其(分布式)服务器上保持会话状态.他们只需要检查每个请求中发送的令牌的有效性.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读