使用Firebase注销

时间:2015-04-27 00:21:38

标签: angularjs firebase

我正在尝试进行用户身份验证,而我现在正处于注销的一部分

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure(facecolor='k')
ax = fig.add_subplot(111, axisbg='k')

def fG(x, x0, sigma, A):
    """ A simple (un-normalized) Gaussian shape with amplitude A. """
    return A * np.exp(-((x-x0)/sigma)**2)

# Draw ny lines with ng Gaussians each, on an x-axis with nx points
nx, ny, ng = 1000, 20, 4
x = np.linspace(0,1,1000)

y = np.zeros((ny, nx))
for iy in range(ny):
    for ig in range(ng):
        # Select the amplitude and position of the Gaussians randomly
        x0 = np.random.random()
        A = np.random.random()*10
        sigma = 0.05
        y[iy,:] += fG(x, x0, sigma, A)
    # Offset each line by this amount: we want the first lines plotted
    # at the top of the chart and to work our way down
    offset = (ny-iy)*5
    # Plot the line and fill under it: increase the z-order each time
    # so that lower lines and their fills are plotted over higher ones
    ax.plot(x,y[iy]+offset, 'w', lw=2, zorder=(iy+1)*2)
    ax.fill_between(x, y[iy]+offset, offset, facecolor='k', lw=0, zorder=(iy+1)*2-1)
plt.show()

这是他们如何登录

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

我试图调用logOut

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

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

在Firebase文档中,他们所说的关于注销的全部是

  

记录用户

     

调用unauth()会使用户的令牌失效并将其记录在应用程序之外:

     

复制   ref.unauth();   如果您之前使用过onAuth()方法来侦听身份验证状态,那么现在将使用null为authData调用回调。

那我该怎么办?

1 个答案:

答案 0 :(得分:3)

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

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

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