diff --git a/web/usercenter/components/UserCenter.tsx b/web/usercenter/components/UserCenter.tsx index 08714ed..ad89fe3 100644 --- a/web/usercenter/components/UserCenter.tsx +++ b/web/usercenter/components/UserCenter.tsx @@ -12,7 +12,7 @@ import Settings from './Settings'; import { useUI } from '../lib/theme'; import { makeT } from '../lib/i18n'; import { apiMode, getClient } from '../lib/api/client'; -import { hasRefresh } from '../lib/api/session'; +import { hasRefresh, clearSession } from '../lib/api/session'; import type { Me } from '../lib/api/types'; type View = 'overview' | 'sub' | 'redeem' | 'invite' | 'settings'; @@ -65,6 +65,10 @@ export default function UserCenter() { await api.refresh(); if (alive) setAuthed(true); } catch { + // 续期失败(refresh token 过期/被撤销/Redis 丢 JTI):清掉本地会话, + // 否则 pg_uc_refresh 残留 → 官网仍显示"用户中心" → 点进来又续期失败 → + // 来回刷登录页。清了官网会回到"Log in",状态一致。 + clearSession(); if (alive) setAuthed(false); } }