이미 클라이언트가 로그인된 상태에서 세션을 업그레이드하려는 경우 발생하던 500 오류 수정

This commit is contained in:
static
2025-07-08 19:38:49 +09:00
parent 983cb2cc57
commit 6e14b45656
3 changed files with 35 additions and 40 deletions

View File

@@ -51,14 +51,7 @@ export const login = async (email: string, password: string, ip: string, userAge
error(401, "Invalid email or password");
}
try {
return { sessionIdSigned: await startSession(user.id, ip, userAgent) };
} catch (e) {
if (e instanceof IntegrityError && e.message === "Session already exists") {
error(403, "Already logged in");
}
throw e;
}
return { sessionIdSigned: await startSession(user.id, ip, userAgent) };
};
export const logout = async (sessionId: string) => {
@@ -115,8 +108,12 @@ export const verifySessionUpgradeChallenge = async (
try {
await upgradeSession(sessionId, client.id);
} catch (e) {
if (e instanceof IntegrityError && e.message === "Session not found") {
error(500, "Invalid challenge answer");
if (e instanceof IntegrityError) {
if (e.message === "Session not found") {
error(500, "Invalid challenge answer");
} else if (e.message === "Session already exists") {
error(403, "Already logged in");
}
}
throw e;
}