Firebase - 撤销刷新令牌不会删除所有活动会话

Firebase - Revoking refresh token doesn't delete all active sessions

我正在尝试在多个设备上注销一个用户的帐户。

为此,在我的后端,我正在做:

async function deleteAccount(userId) {
  // Close all the current active sessions
  await closeAllUserActiveSessions(userId);

  return auth.deleteUser(userId);
}

async function closeAllUserActiveSessions(userId) {
  await auth.revokeRefreshTokens(userId);
  const userRecord = await auth.getUser(userId);
  const timestamp = new Date(userRecord.tokensValidAfterTime).getTime() / 1000;

  functions.logger.log(`Tokens revoked at: ${timestamp}`);
}

我原以为,在调用 auth.revokeRefreshTokens(userId) 之后,该帐户会在所有设备上自动注销,但事实并非如此。

是否可以退出所有会话? auth.revokeRefreshTokens(userId)有什么用?

我只是想在用户更改密码或删除帐户时注销我的用户帐户(从所有设备)...有什么想法吗?

您看到的行为符合预期:ID 令牌是不记名令牌,一旦铸造就无法撤销。

如果您希望在 revoking the refresh token, you'll need to detect the revocation 之后在每个使用 ID 令牌建立调用者身份的后端服务中拒绝现有 ID 令牌。

当用户更改密码时,不会直接通知其他客户端,因此您必须自己发送此类通知。