대시보드와 주간보고 기능 업데이트

This commit is contained in:
2026-01-10 14:40:01 +09:00
parent 0dd4b561f0
commit e4627caa4c
26 changed files with 3329 additions and 1720 deletions

View File

@@ -1,26 +1,33 @@
import { execute } from '../../utils/db'
import { getClientIp } from '../../utils/ip'
import { getSession, deleteSession, getSessionIdFromCookie, deleteSessionCookie } from '../../utils/session'
/**
* 로그아웃
* POST /api/auth/logout
*/
export default defineEventHandler(async (event) => {
const historyId = getCookie(event, 'login_history_id')
const sessionId = getSessionIdFromCookie(event)
const clientIp = getClientIp(event)
// 로그아웃 이력 기록
if (historyId) {
await execute(`
UPDATE wr_login_history
SET logout_at = NOW(), logout_ip = $1
WHERE history_id = $2
`, [clientIp, historyId])
if (sessionId) {
// 세션 정보 조회
const session = await getSession(sessionId)
// 로그아웃 이력 기록
if (session?.loginHistoryId) {
await execute(`
UPDATE wr_login_history
SET logout_at = NOW(), logout_ip = $1
WHERE history_id = $2
`, [clientIp, session.loginHistoryId])
}
// DB에서 세션 삭제
await deleteSession(sessionId)
}
// 쿠키 삭제
deleteCookie(event, 'user_id')
deleteCookie(event, 'login_history_id')
// 세션 쿠키 삭제
deleteSessionCookie(event)
return { success: true }
})