使用 Firebase 注销
Logout with Firebase
我正在尝试做一个用户认证,我现在在注销部分
<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();
};
调用注销后,我没有看到任何 post 或进入浏览器的“网络”部分。
在 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.
所以我应该在这里做什么?
关于注销不显示任何网络activity:登录时 firebase 可能会在您登录时为您提供访问令牌(由 firebase 客户端脚本保存)。
当登录后您的应用程序访问 firebase 时,它会将此令牌添加到您的请求的 header(授权 header?)。
当您注销时,firebase 客户端脚本会简单地删除令牌。这样,firebase 后端就不必在其(分布式)服务器上保持 session 状态。他们只需要检查每个请求中发送的令牌的有效性。
我正在尝试做一个用户认证,我现在在注销部分
<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();
};
调用注销后,我没有看到任何 post 或进入浏览器的“网络”部分。
在 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.
所以我应该在这里做什么?
关于注销不显示任何网络activity:登录时 firebase 可能会在您登录时为您提供访问令牌(由 firebase 客户端脚本保存)。
当登录后您的应用程序访问 firebase 时,它会将此令牌添加到您的请求的 header(授权 header?)。
当您注销时,firebase 客户端脚本会简单地删除令牌。这样,firebase 后端就不必在其(分布式)服务器上保持 session 状态。他们只需要检查每个请求中发送的令牌的有效性。