17 lines
486 B
TypeScript
17 lines
486 B
TypeScript
import type { H3Event } from 'h3'
|
|
import { queryOne } from './db'
|
|
|
|
/**
|
|
* 현재 로그인한 사용자의 이메일 조회
|
|
*/
|
|
export async function getCurrentUserEmail(event: H3Event): Promise<string | null> {
|
|
const userId = getCookie(event, 'user_id')
|
|
if (!userId) return null
|
|
|
|
const user = await queryOne<{ employee_email: string }>(`
|
|
SELECT employee_email FROM wr_employee_info WHERE employee_id = $1
|
|
`, [parseInt(userId)])
|
|
|
|
return user?.employee_email || null
|
|
}
|