Files
weeklyreport/backend/api/auth/logout.post.ts
2026-01-04 20:58:47 +09:00

27 lines
625 B
TypeScript

import { execute } from '../../utils/db'
import { getClientIp } from '../../utils/ip'
/**
* 로그아웃
* POST /api/auth/logout
*/
export default defineEventHandler(async (event) => {
const historyId = getCookie(event, 'login_history_id')
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])
}
// 쿠키 삭제
deleteCookie(event, 'user_id')
deleteCookie(event, 'login_history_id')
return { success: true }
})