fix(388-1 보안): 계정 바뀜 판정 — 수 id 를 글로 견줌(새로고침 되풀이 막음)

- 서버 사용자 id 가 수(3)로 와 저장값 "3" 과 늘 달라 지움 · 새로고침이 되풀이됨
- String() 으로 같은 꼴 견줌 · 시험에 수 id 경우 더함

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmC34fsxxbweEG3RUjs3Mn
This commit is contained in:
2026-10-17 17:35:48 +09:00
co-authored by Claude Opus 5.5
parent 3e312b68d7
commit 1eb9c0f0b7
3 changed files with 6 additions and 1 deletions
+2 -1
View File
@@ -140,7 +140,8 @@ export async function wipeAccountCache(): Promise<void> {
}
/** 로그인 확인 때 — 앞서 자료를 남긴 계정과 다르면 지우고 true(부른 쪽이 새로고침). */
export async function wipeIfOwnerChanged(userId: string): Promise<boolean> {
export async function wipeIfOwnerChanged(user: string | number): Promise<boolean> {
const userId = String(user); // 서버 id 가 수로 옴 — 저장값(글)과 같은 꼴로 견줌
let previous: string | null = null;
try {
previous = window.localStorage.getItem(OWNER_KEY);
@@ -100,6 +100,9 @@ const tick = () => new Promise((r) => setTimeout(r, 0));
out.owner.otherKeys = sessionKeys().length;
out.owner.otherProject = local("frd_current_project_id");
out.owner.stored = local("aislo:owner");
// 서버 id 가 수로 옴 — 같은 계정 수 id 는 두 번째에 안 지움(새로고침 되풀이 막음)
await sw.wipeIfOwnerChanged(3);
out.owner.numericAgain = await sw.wipeIfOwnerChanged(3);
// 세션 넘침 — 결과 칸 비우고 다시 · 그래도 넘치면 안내
global.window.sessionStorage = fakeStorage(400);
@@ -44,6 +44,7 @@ def test_계정_바뀜_지움(out):
assert owner["same"] is False and owner["sameKeys"] == 4
assert owner["other"] is True and owner["otherKeys"] == 0
assert owner["otherProject"] is None and owner["stored"] == "u2"
assert owner["numericAgain"] is False # 수 id 3 == 저장 "3"
def test_세션_넘침_결과_비우고_다시(out):