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

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,5 +1,5 @@
import { query, insertReturning, execute } from '../../utils/db'
import { getClientIp } from '../../utils/ip'
import { createSession, setSessionCookie } from '../../utils/session'
interface LoginBody {
email: string
@@ -7,12 +7,13 @@ interface LoginBody {
}
/**
* 이메일+이름 로그인 (임시)
* 이메일+이름 로그인
* POST /api/auth/login
*/
export default defineEventHandler(async (event) => {
const body = await readBody<LoginBody>(event)
const clientIp = getClientIp(event)
const userAgent = getHeader(event, 'user-agent') || null
if (!body.email || !body.name) {
throw createError({ statusCode: 400, message: '이메일과 이름을 입력해주세요.' })
@@ -60,18 +61,16 @@ export default defineEventHandler(async (event) => {
RETURNING history_id
`, [employeeData.employee_id, clientIp, emailLower])
// 쿠키에 사용자 정보 저장
setCookie(event, 'user_id', String(employeeData.employee_id), {
httpOnly: true,
maxAge: 60 * 60 * 24 * 7,
path: '/'
})
// DB 기반 세션 생성
const sessionId = await createSession(
employeeData.employee_id,
loginHistory.history_id,
clientIp,
userAgent
)
setCookie(event, 'login_history_id', String(loginHistory.history_id), {
httpOnly: true,
maxAge: 60 * 60 * 24 * 7,
path: '/'
})
// 세션 쿠키 설정
setSessionCookie(event, sessionId)
return {
success: true,