diff options
Diffstat (limited to 'app/api')
| -rw-r--r-- | app/api/auth/[...nextauth]/route.ts | 42 | ||||
| -rw-r--r-- | app/api/cron/forms/route.ts | 21 | ||||
| -rw-r--r-- | app/api/cron/object-classes/route.ts | 21 | ||||
| -rw-r--r-- | app/api/cron/projects/route.ts | 21 | ||||
| -rw-r--r-- | app/api/cron/tag-types/route.ts | 20 |
5 files changed, 123 insertions, 2 deletions
diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index 609a63d7..cd91774c 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -8,7 +8,7 @@ import { JWT } from "next-auth/jwt" import CredentialsProvider from 'next-auth/providers/credentials' -import { verifyOtp } from '@/lib/users/verifyOtp' +import { verifyExternalCredentials, verifyOtp } from '@/lib/users/verifyOtp' // 1) 모듈 보강 선언 declare module "next-auth" { @@ -61,7 +61,7 @@ export const authOptions: NextAuthOptions = { } return { - id: String(user.id ?? email ?? "dts"), + id: String(user.id ?? email ?? "dts"), email: user.email, imageUrl: user.imageUrl ?? null, name: user.name, // DB에서 가져온 실제 이름 @@ -69,6 +69,44 @@ export const authOptions: NextAuthOptions = { domain: user.domain, // DB에서 가져온 실제 이름 } }, + }), + // 새로 추가할 ID/비밀번호 provider + CredentialsProvider({ + id: 'credentials-password', + name: 'Username Password', + credentials: { + username: { label: "Username", type: "text" }, + password: { label: "Password", type: "password" } + }, + async authorize(credentials, req) { // req 매개변수 추가 + if (!credentials?.username || !credentials?.password) { + return null; + } + + try { + // 여기서 외부 서비스 API를 호출하여 사용자 인증 + const user = await verifyExternalCredentials( + credentials.username, + credentials.password + ); + + if (user) { + return { + id: String(user.id), // id를 string으로 변환 + name: user.name, + email: user.email, + // 첫 번째 provider와 동일한 필드 구조 유지 + imageUrl: user.imageUrl ?? null, + companyId: user.companyId, + domain: user.domain + }; + } + return null; + } catch (error) { + console.error("Authentication error:", error); + return null; + } + } }) ], // (3) session.strategy는 'jwt'가 되도록 선언 diff --git a/app/api/cron/forms/route.ts b/app/api/cron/forms/route.ts new file mode 100644 index 00000000..f58c146b --- /dev/null +++ b/app/api/cron/forms/route.ts @@ -0,0 +1,21 @@ +// src/app/api/cron/tag-form-mappings/route.ts +import { syncTagFormMappings } from '@/lib/sedp/sync-form'; +import { NextRequest } from 'next/server'; + +export async function GET(request: NextRequest) { + try { + console.log('태그 폼 매핑 동기화 API 호출됨:', new Date().toISOString()); + + // syncTagFormMappings 함수 호출 + const result = await syncTagFormMappings(); + + // 성공 시 결과와 함께 200 OK 반환 + return Response.json({ success: true, result }, { status: 200 }); + } catch (error: any) { + console.error('태그 폼 매핑 동기화 API 에러:', error); + + // 에러 시에는 message를 담아 500 반환 + const message = error.message || 'Something went wrong'; + return Response.json({ success: false, error: message }, { status: 500 }); + } +}
\ No newline at end of file diff --git a/app/api/cron/object-classes/route.ts b/app/api/cron/object-classes/route.ts new file mode 100644 index 00000000..9a574b1b --- /dev/null +++ b/app/api/cron/object-classes/route.ts @@ -0,0 +1,21 @@ +// src/app/api/cron/object-classes/route.ts +import { syncObjectClasses } from '@/lib/sedp/sync-object-class'; +import { NextRequest } from 'next/server'; + +export async function GET(request: NextRequest) { + try { + console.log('오브젝트 클래스 동기화 API 호출됨:', new Date().toISOString()); + + // syncObjectClasses 함수 호출 + const result = await syncObjectClasses(); + + // 성공 시 결과와 함께 200 OK 반환 + return Response.json({ success: true, result }, { status: 200 }); + } catch (error: any) { + console.error('오브젝트 클래스 동기화 API 에러:', error); + + // 에러 시에는 message를 담아 500 반환 + const message = error.message || 'Something went wrong'; + return Response.json({ success: false, error: message }, { status: 500 }); + } +}
\ No newline at end of file diff --git a/app/api/cron/projects/route.ts b/app/api/cron/projects/route.ts new file mode 100644 index 00000000..d8e6af51 --- /dev/null +++ b/app/api/cron/projects/route.ts @@ -0,0 +1,21 @@ +// src/app/api/cron/projects/route.ts +import { syncProjects } from '@/lib/sedp/sync-projects'; +import { NextRequest } from 'next/server'; + +export async function GET(request: NextRequest) { + try { + console.log('프로젝트 동기화 API 호출됨:', new Date().toISOString()); + + // syncProjects 함수 호출 + const result = await syncProjects(); + + // 성공 시 결과와 함께 200 OK 반환 + return Response.json({ success: true, result }, { status: 200 }); + } catch (error: any) { + console.error('프로젝트 동기화 API 에러:', error); + + // 에러 시에는 message를 담아 500 반환 + const message = error.message || 'Something went wrong'; + return Response.json({ success: false, error: message }, { status: 500 }); + } +}
\ No newline at end of file diff --git a/app/api/cron/tag-types/route.ts b/app/api/cron/tag-types/route.ts new file mode 100644 index 00000000..35145984 --- /dev/null +++ b/app/api/cron/tag-types/route.ts @@ -0,0 +1,20 @@ +import { syncTagSubfields } from '@/lib/sedp/sync-tag-types'; +import { NextRequest } from 'next/server'; + +export async function GET(request: NextRequest) { + try { + console.log('태그 서브필드 동기화 API 호출됨:', new Date().toISOString()); + + // syncTagSubfields 함수 호출 + const result = await syncTagSubfields(); + + // 성공 시 결과와 함께 200 OK 반환 + return Response.json({ success: true, result }, { status: 200 }); + } catch (error: any) { + console.error('태그 서브필드 동기화 API 에러:', error); + + // 에러 시에는 message를 담아 500 반환 + const message = error.message || 'Something went wrong'; + return Response.json({ success: false, error: message }, { status: 500 }); + } +}
\ No newline at end of file |
