Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/API_SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ YYYY-MM-DDTHH:mm:ssZ
"success": true,
"data": {
"id": "uuid",
"nickname": "string",
"name": "string | null",
"nickname": "string | null",
Comment on lines +336 to +337

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

GET 응답 명세와 실제 구현 DTO가 불일치합니다.

Line 336-337, Line 358에서 name을 응답 계약에 추가했지만, 제공된 구현 스니펫(src/app/api/users/me/route.ts:8-41)은 name을 조회/반환하지 않습니다. 현재 상태면 name 우선 표시 정책이 서버 응답에서 성립하지 않습니다.

예시 수정안 (서버 구현 동기화)
 interface UserMeDto {
   id: string
+  name: string | null
   nickname: string | null
   mbti: string | null
 }

 const user = await prisma.user.findUnique({
   where: { id: userId },
-  select: { id: true, nickname: true, mbti: true },
+  select: { id: true, name: true, nickname: true, mbti: true },
 })

 return NextResponse.json<ApiResponse<UserMeDto>>({
   success: true,
-  data: { id: user.id, nickname: user.nickname, mbti: user.mbti },
+  data: { id: user.id, name: user.name, nickname: user.nickname, mbti: user.mbti },
 })

Also applies to: 358-358

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/API_SPEC.md` around lines 336 - 337, The API specification document
defines "name" and "nickname" fields in the GET response contract (lines 336-337
and 358), but the implementation in the route handler
(src/app/api/users/me/route.ts at lines 8-41) does not retrieve or return these
fields. Update the route handler to query and include the "name" and "nickname"
fields in the response object so that the actual implementation matches the API
specification contract.

"profileImageUrl": "string | null",
"gender": "male | female | other | unknown | no_answer | null",
"ageGroup": "under_10 | teens | twenties | thirties | forties | fifties | sixties_plus | unknown | no_answer | null",
Expand All @@ -354,6 +355,7 @@ YYYY-MM-DDTHH:mm:ssZ

- **처리 정책:**
- 본인 정보만 조회 가능
- `name`이 있으면 name 우선 표시, null이면 nickname 표시
- `deletedAt`이 있는 탈퇴 계정 처리 기준 확정 필요
- MVP에서 `profileImageUrl`은 카카오 프로필 이미지 URL 그대로 반환 (Supabase Storage 미사용)
- **확정 필요:**
Expand All @@ -370,7 +372,8 @@ YYYY-MM-DDTHH:mm:ssZ

```json
{
"nickname": "string (optional)",
"name": "string (optional, 1~50자)",
"nickname": "string (optional, 2~20자)",
Comment on lines +375 to +376

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

PATCH 요청/응답 명세가 현재 서버 검증 로직과 맞지 않습니다.

Line 375-376, Line 390-391 기준으로 name(1~50) 및 nickname(2~20) 계약을 명시했지만, 제공된 PATCH 스니펫(src/app/api/user/me/route.ts:103-141)은 name을 처리하지 않고 nickname을 2~100자로 검증합니다. 명세-구현 간 계약 불일치로 클라이언트/서버 통합 오류가 발생할 수 있습니다.

Also applies to: 390-391

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/API_SPEC.md` around lines 375 - 376, The PATCH request/response
specification in the API_SPEC.md file defines name as a 1-50 character optional
field and nickname as a 2-20 character optional field, but the PATCH handler in
the user/me route does not match these constraints. Update the PATCH handler in
src/app/api/user/me/route.ts to add validation for the name field (1-50
characters) and fix the nickname validation to enforce a 2-20 character range
instead of the current 2-100 character range to align the implementation with
the documented API specification.

"gender": "male | female | other | no_answer (optional)",
"ageGroup": "string (optional)",
"mbti": "string (optional, 4자)"
Expand All @@ -384,7 +387,8 @@ YYYY-MM-DDTHH:mm:ssZ
"success": true,
"data": {
"id": "uuid",
"nickname": "string",
"name": "string | null",
"nickname": "string | null",
"gender": "string | null",
"ageGroup": "string | null",
"mbti": "string | null"
Expand Down
8 changes: 6 additions & 2 deletions src/app/(page)/mypage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Header from '@/components/layout/Header';
import BottomNavigation from '@/components/layout/BottomNavigation';
import Avatar from '@/components/ui/Avatar';
import ConfirmModal from '@/components/ui/ConfirmModal';
import { useUserMe } from '@/domains/user/hooks';
import SettingsRoundedIcon from '@mui/icons-material/SettingsRounded';
import ChevronRightRoundedIcon from '@mui/icons-material/ChevronRightRounded';
import styles from './page.module.scss';
Expand All @@ -22,9 +23,12 @@ const LINK_ITEMS = [

export default function MyPage() {
const router = useRouter();
const { data: user } = useUserMe();
const [logoutOpen, setLogoutOpen] = useState(false);
const [withdrawOpen, setWithdrawOpen] = useState(false);

const displayName = user?.name ?? user?.nickname ?? '';

const handleLogout = () => {
signOut({ callbackUrl: '/login' });
};
Expand All @@ -41,8 +45,8 @@ export default function MyPage() {
<section className={styles.profile}>
<Avatar size="l" />
<div className={styles.profile__info}>
<span className={styles.profile__name}>생각하는부엉이</span>
<span className={styles.profile__badge}>ISTJ</span>
<span className={styles.profile__name}>{displayName}</span>
{user?.mbti && <span className={styles.profile__badge}>{user.mbti}</span>}
</div>
<Link href="/mypage/edit" className={styles.profile__setting} aria-label="설정">
<SettingsRoundedIcon sx={{ fontSize: 24 }} />
Expand Down
3 changes: 2 additions & 1 deletion src/components/home/HomeGreeting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import styles from '@/app/page.module.scss'
export default function HomeGreeting() {
const { data: user } = useUserMe()

const greeting = user?.nickname ? `${user.nickname}님` : '안녕하세요'
const displayName = user?.name ?? user?.nickname
const greeting = displayName ? `${displayName}님` : '안녕하세요'

return (
<section className={styles.greeting}>
Expand Down
26 changes: 25 additions & 1 deletion src/lib/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,31 @@ const MAX_NICKNAME_RETRIES = 10
async function saveFirstLoginFields(userId: string, kakaoId: string): Promise<void> {
const now = new Date()

const user = await prisma.user.findUnique({
where: { id: userId },
select: { name: true },
})

if (user?.name) {
await prisma.$transaction([
prisma.user.update({
where: { id: userId },
data: { kakaoId, termsAgreedAt: now },
}),
prisma.userTermsAgreement.createMany({
data: Object.values(CURRENT_TERMS_VERSIONS).map((terms) => ({
userId,
termsType: terms.type,
termsVersion: terms.version,
isRequired: terms.isRequired,
agreedAt: now,
})),
skipDuplicates: true,
}),
])
return
}

for (let attempt = 0; attempt < MAX_NICKNAME_RETRIES; attempt++) {
const isLastAttempt = attempt === MAX_NICKNAME_RETRIES - 1
const nickname = isLastAttempt
Expand Down Expand Up @@ -109,7 +134,6 @@ export const authOptions: NextAuthOptions = {
},
events: {
async createUser({ user }) {
// PrismaAdapter가 User를 생성한 직후 호출됨 — 신규 사용자 커스텀 필드 설정
const account = await prisma.account.findFirst({
where: { userId: user.id, provider: 'kakao' },
select: { providerAccountId: true },
Expand Down