diff options
| author | joonhoekim <26rote@gmail.com> | 2025-10-13 18:24:00 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-10-13 18:24:00 +0900 |
| commit | 80e3d0befed487e0447bacffd76ed6539f01e992 (patch) | |
| tree | de5762bea7161e3dd949401b2d985b6723fd32ee /app/api | |
| parent | ff8a168f9fc67b345f4d32065e55f0901ba05b4c (diff) | |
(김준회) S-GIPS 로그인시 유저 선택해 sms 전송 처리
Diffstat (limited to 'app/api')
| -rw-r--r-- | app/api/auth/first-auth/route.ts | 19 | ||||
| -rw-r--r-- | app/api/auth/select-sgips-user/route.ts | 85 |
2 files changed, 104 insertions, 0 deletions
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<NextResponse<FirstAuth } // 1차 인증 성공 응답 + // S-GIPS의 경우 otpUsers 배열 반환 + if (provider === 'sgips' && authResult.otpUsers) { + return NextResponse.json({ + success: true, + otpUsers: authResult.otpUsers + }) + } + + // 일반 사용자의 경우 기존 응답 return NextResponse.json({ success: true, tempAuthKey: authResult.tempAuthKey, diff --git a/app/api/auth/select-sgips-user/route.ts b/app/api/auth/select-sgips-user/route.ts new file mode 100644 index 00000000..75c2012f --- /dev/null +++ b/app/api/auth/select-sgips-user/route.ts @@ -0,0 +1,85 @@ +// /api/auth/select-sgips-user/route.ts +// 선택된 S-GIPS 사용자에 대한 임시 인증 세션 생성 API 엔드포인트 + +import { authHelpers } from '@/lib/users/session/helper' +import { NextRequest, NextResponse } from 'next/server' + +// 요청 데이터 타입 +interface SelectUserRequest { + userId: number + email: string + name: string +} + +// 응답 데이터 타입 +interface SelectUserResponse { + success: boolean + tempAuthKey?: string + userId?: number + email?: string + error?: string +} + +export async function POST(request: NextRequest): Promise<NextResponse<SelectUserResponse>> { + 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 } + ) +} |
