마지막 접속 IP와 User Agent가 빈 값인 경우 DB에 해당 정보를 기록하지 않도록 수정

This commit is contained in:
static
2025-01-13 03:17:54 +09:00
parent 68a764bf28
commit 6a64bb45f2

View File

@@ -20,8 +20,8 @@ export const createSession = async (
clientId, clientId,
createdAt: now, createdAt: now,
lastUsedAt: now, lastUsedAt: now,
lastUsedByIp: ip, lastUsedByIp: ip || null,
lastUsedByUserAgent: userAgent, lastUsedByUserAgent: userAgent || null,
}); });
} catch (e) { } catch (e) {
if (e instanceof SqliteError && e.code === "SQLITE_CONSTRAINT_UNIQUE") { if (e instanceof SqliteError && e.code === "SQLITE_CONSTRAINT_UNIQUE") {
@@ -41,8 +41,8 @@ export const refreshSession = async (
.update(session) .update(session)
.set({ .set({
lastUsedAt: now, lastUsedAt: now,
lastUsedByIp: ip ?? undefined, lastUsedByIp: ip || undefined,
lastUsedByUserAgent: userAgent ?? undefined, lastUsedByUserAgent: userAgent || undefined,
}) })
.where( .where(
and( and(