fix(auth): 退出授权清除匿名访客身份,登出后不再被自动重登
This commit is contained in:
parent
9e37d4a034
commit
43cb20eeb4
|
|
@ -50,6 +50,15 @@ function ensureVisitorId(): string {
|
|||
}
|
||||
}
|
||||
|
||||
export function resetVisitorId(): void {
|
||||
memoryVisitorId = null;
|
||||
try {
|
||||
window.localStorage.removeItem(ANONYMOUS_VISITOR_KEY);
|
||||
} catch {
|
||||
// 隐私模式等场景下 localStorage 不可用,忽略即可
|
||||
}
|
||||
}
|
||||
|
||||
let desktopDeviceId: Promise<string> | null = null;
|
||||
|
||||
async function getDesktopDeviceId(): Promise<string> {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
SafetyCertificateOutlined, UserOutlined, WarningOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
import { clientFetch, getClientMode, type ClientMode } from '../api/client';
|
||||
import { clientFetch, getClientMode, resetVisitorId, type ClientMode } from '../api/client';
|
||||
|
||||
export type AuthUser = {
|
||||
user_id: string;
|
||||
|
|
@ -184,6 +184,7 @@ export function AuthProvider(props: { children: ReactNode }) {
|
|||
await clientFetch('/api/auth/logout', { method: 'POST' });
|
||||
} finally {
|
||||
clearSensitiveBrowserState();
|
||||
resetVisitorId();
|
||||
await refresh();
|
||||
}
|
||||
}, [refresh]);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ from server.contracts import INTERFACE_VERSION, IntentResult # 跨层握手与
|
|||
from server.state.checkpoints import get_checkpoints # 成对快照仓(时间线)
|
||||
from server.state.store import get_store # 世界状态单例
|
||||
from server.auth.context import get_identity
|
||||
from server.auth.middleware import AuthenticationMiddleware
|
||||
from server.auth.middleware import ANONYMOUS_COOKIE, AuthenticationMiddleware
|
||||
from server.auth.licenses import (
|
||||
DESKTOP_COOKIE,
|
||||
WEB_LICENSE_COOKIE,
|
||||
|
|
@ -1219,6 +1219,7 @@ def create_app() -> FastAPI:
|
|||
response.delete_cookie("aps_session", path="/")
|
||||
response.delete_cookie(DESKTOP_COOKIE, path="/")
|
||||
response.delete_cookie(WEB_LICENSE_COOKIE, path="/")
|
||||
response.delete_cookie(ANONYMOUS_COOKIE, path="/")
|
||||
return {"ok": True}
|
||||
|
||||
@app.get("/api/auth/users")
|
||||
|
|
|
|||
Loading…
Reference in New Issue