From 80e3d0befed487e0447bacffd76ed6539f01e992 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Mon, 13 Oct 2025 18:24:00 +0900 Subject: (김준회) S-GIPS 로그인시 유저 선택해 sms 전송 처리 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/auth/first-auth/route.ts | 19 ++++++++ app/api/auth/select-sgips-user/route.ts | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 app/api/auth/select-sgips-user/route.ts (limited to 'app/api/auth') diff --git a/app/api/auth/first-auth/route.ts b/app/api/auth/first-auth/route.ts index e8d86a02..6952b472 100644 --- a/app/api/auth/first-auth/route.ts +++ b/app/api/auth/first-auth/route.ts @@ -17,6 +17,16 @@ interface FirstAuthResponse { tempAuthKey?: string userId?: number email?: string + otpUsers?: Array<{ + id: string + name: string + vndrcd: string + phone: string + email: string + nation_cd: string + userId: number + vendorInfo?: any + }> error?: string errorCode?: string } @@ -116,6 +126,15 @@ export async function POST(request: NextRequest): Promise> { + try { + // 요청 데이터 파싱 + const body: SelectUserRequest = await request.json() + const { userId, email, name } = body + + // 입력 검증 + if (!userId || !email || !name) { + return NextResponse.json( + { + success: false, + error: '필수 입력값이 누락되었습니다.' + }, + { status: 400 } + ) + } + + // 선택된 사용자에 대한 임시 인증 세션 생성 + const result = await authHelpers.createTempAuthForSelectedUser({ + userId, + email, + name + }) + + if (!result.success) { + return NextResponse.json( + { + success: false, + error: '임시 인증 세션 생성에 실패했습니다.' + }, + { status: 500 } + ) + } + + // 성공 응답 + return NextResponse.json({ + success: true, + tempAuthKey: result.tempAuthKey, + userId: result.userId, + email: result.email + }) + + } catch (error) { + console.error('Select S-GIPS user API error:', error) + + // 에러 응답 + return NextResponse.json( + { + success: false, + error: '서버 오류가 발생했습니다. 잠시 후 다시 시도해주세요.' + }, + { status: 500 } + ) + } +} + +// GET 요청은 지원하지 않음 +export async function GET() { + return NextResponse.json( + { error: 'Method not allowed' }, + { status: 405 } + ) +} -- cgit v1.2.3