Files
todo/nextjs/src/shared/lib/auth.ts
Mayne0213 b5bb97aa16
Some checks failed
Build Docker Image / build-and-push (push) Has been cancelled
CI / lint-and-build (push) Has been cancelled
REFACTOR(repo): simplify project structure
- Move services/nextjs/ to nextjs/
- Move Dockerfile.prod to Dockerfile at root
- Remove deploy/ folder (K8s manifests moved to K3S-HOME/web-apps)
- Remove .gitea/ workflows
- Update GitHub Actions for new structure
- Remove develop branch triggers
2026-01-05 02:03:53 +09:00

28 lines
633 B
TypeScript

import { NextRequest } from 'next/server'
export const SESSION_COOKIE_NAME = 'todo-auth-session'
/**
* 요청이 인증되었는지 확인
*/
export function isAuthenticated(request: NextRequest): boolean {
const session = request.cookies.get(SESSION_COOKIE_NAME)?.value
return session === 'authenticated'
}
/**
* 인증되지 않은 요청에 대한 응답 생성
*/
export function createUnauthorizedResponse() {
return new Response(
JSON.stringify({ success: false, error: '인증이 필요합니다' }),
{
status: 401,
headers: {
'Content-Type': 'application/json',
},
}
)
}