用户变动撤销所有刷新token,立即失效accesstoken

This commit is contained in:
mtvpls
2026-06-17 11:35:46 +08:00
parent 84afb97f9f
commit d7727455dc
9 changed files with 118 additions and 4 deletions
+2
View File
@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { invalidateDeviceAccessToken } from '@/lib/access-token-invalidation';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getStorage } from '@/lib/db';
import { revokeRefreshToken } from '@/lib/refresh-token';
@@ -12,6 +13,7 @@ export async function POST(request: NextRequest) {
// 撤销当前设备的 Refresh Token
if (authInfo && authInfo.username && authInfo.tokenId) {
try {
invalidateDeviceAccessToken(authInfo.username, authInfo.tokenId);
await revokeRefreshToken(authInfo.username, authInfo.tokenId);
const storage = getStorage();
await storage.deletePushSubscriptionsByTokenId?.(authInfo.username, authInfo.tokenId);