CHORE(merge): merge from develop
- Initial setup and all features from develop branch - Includes: auth, deploy, docker, style fixes - K3S deployment configuration
This commit is contained in:
4
nextjs/app/api/auth/[...nextauth]/route.ts
Normal file
4
nextjs/app/api/auth/[...nextauth]/route.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { handlers } from "@/lib/auth";
|
||||
|
||||
export const { GET, POST } = handlers;
|
||||
|
||||
31
nextjs/app/api/auth/me/route.ts
Normal file
31
nextjs/app/api/auth/me/route.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@/lib/auth";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const session = await auth();
|
||||
|
||||
if (!session?.user) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "로그인 필요", user: null },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: {
|
||||
id: parseInt(session.user.id),
|
||||
userId: session.user.userId,
|
||||
userName: session.user.name,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Get user error:", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "서버 오류가 발생했습니다.", user: null },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
95
nextjs/app/api/auth/signup/route.ts
Normal file
95
nextjs/app/api/auth/signup/route.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import bcrypt from "bcryptjs";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
try {
|
||||
const {
|
||||
userId,
|
||||
userPassword,
|
||||
userCheckPassword,
|
||||
userName,
|
||||
userPhone,
|
||||
authCode,
|
||||
} = await req.json();
|
||||
|
||||
// 유효성 검사
|
||||
if (!userId || !userPassword || !userCheckPassword || !userName || !userPhone || !authCode) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "필수 정보를 모두 입력해주세요." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// 승인번호 검사
|
||||
if (authCode !== process.env.CODE) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "승인번호가 올바르지 않습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// 비밀번호 확인
|
||||
if (userPassword !== userCheckPassword) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "비밀번호가 일치하지 않습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// 중복 체크: 아이디
|
||||
const existingUser = await prisma.user.findUnique({
|
||||
where: { userId },
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "이미 사용 중인 아이디입니다." },
|
||||
{ status: 409 }
|
||||
);
|
||||
}
|
||||
|
||||
// 중복 체크: 전화번호
|
||||
const existingPhone = await prisma.user.findUnique({
|
||||
where: { userPhone },
|
||||
});
|
||||
|
||||
if (existingPhone) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "이미 등록된 전화번호입니다." },
|
||||
{ status: 409 }
|
||||
);
|
||||
}
|
||||
|
||||
// 비밀번호 해싱
|
||||
const hashedPassword = await bcrypt.hash(userPassword, 10);
|
||||
|
||||
// 새로운 유저 생성
|
||||
const newUser = await prisma.user.create({
|
||||
data: {
|
||||
userId,
|
||||
userPassword: hashedPassword,
|
||||
userName,
|
||||
userPhone,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
data: {
|
||||
userId: newUser.userId,
|
||||
userName: newUser.userName,
|
||||
},
|
||||
},
|
||||
{ status: 201 }
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("Signup error:", err);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "서버 오류가 발생했습니다." },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user