summaryrefslogtreecommitdiff
path: root/app/api/auth/send-sms/route.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/api/auth/send-sms/route.ts')
-rw-r--r--app/api/auth/send-sms/route.ts20
1 files changed, 9 insertions, 11 deletions
diff --git a/app/api/auth/send-sms/route.ts b/app/api/auth/send-sms/route.ts
index 3d51d445..6b9eb114 100644
--- a/app/api/auth/send-sms/route.ts
+++ b/app/api/auth/send-sms/route.ts
@@ -4,7 +4,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { z } from 'zod';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/app/api/auth/[...nextauth]/route';
-import { getUserById } from '@/lib/users/repository';
+import { getUserByEmail, getUserById } from '@/lib/users/repository';
import { generateAndSendSmsToken } from '@/lib/users/auth/passwordUtil';
const sendSmsSchema = z.object({
@@ -13,20 +13,14 @@ const sendSmsSchema = z.object({
export async function POST(request: NextRequest) {
try {
- // 세션 확인
- const session = await getServerSession(authOptions);
- if (!session?.user?.id) {
- return NextResponse.json(
- { error: '인증이 필요합니다' },
- { status: 401 }
- );
- }
const body = await request.json();
const { userId } = sendSmsSchema.parse(body);
+ console.log(userId, "userId")
+
// 본인 확인
- if (session.user.id !== userId) {
+ if (!userId) {
return NextResponse.json(
{ error: '권한이 없습니다' },
{ status: 403 }
@@ -42,8 +36,12 @@ export async function POST(request: NextRequest) {
);
}
+ console.log(user, "user")
+
+
+
// SMS 전송
- const result = await generateAndSendSmsToken(parseInt(userId), user.phone);
+ const result = await generateAndSendSmsToken(Number(userId), user.phone);
if (result.success) {
return NextResponse.json({