강제 로그인 기능 추가

This commit is contained in:
static
2025-07-11 23:15:35 +09:00
parent fa8c163347
commit c47885d571
18 changed files with 187 additions and 98 deletions

View File

@@ -87,9 +87,11 @@ export const createSessionUpgradeChallenge = async (
export const verifySessionUpgradeChallenge = async (
sessionId: string,
userId: number,
ip: string,
challengeId: number,
answerSig: string,
force: boolean,
) => {
const challenge = await consumeSessionUpgradeChallenge(challengeId, sessionId, ip);
if (!challenge) {
@@ -106,13 +108,13 @@ export const verifySessionUpgradeChallenge = async (
}
try {
await upgradeSession(sessionId, client.id);
await upgradeSession(userId, sessionId, client.id, force);
} catch (e) {
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");
} else if (!force && e.message === "Session already exists") {
error(409, "Already logged in");
}
}
throw e;