Skip to content

Commit da0d2eb

Browse files
authored
fix : partyJoinError (#71)
1 parent f077231 commit da0d2eb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

backend/src/main/java/com/back/domain/party/party/controller/ApiV1PartyController.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.back.domain.party.party.controller;
22

3+
import com.back.domain.member.entity.Member;
4+
import com.back.domain.member.service.MemberService;
35
import com.back.domain.mission.entity.Mission;
46
import com.back.domain.mission.enums.MissionCategory;
57
import com.back.domain.party.party.dto.*;
@@ -33,16 +35,24 @@
3335
public class ApiV1PartyController {
3436

3537
private final PartyService partyService;
38+
private final MemberService memberService;
39+
3640

3741
// Authentication 객체로부터 사용자 ID를 안전하게 가져오는 헬퍼 메서드
3842
private Integer getMemberIdFromAuthentication(Authentication authentication) {
3943
if (authentication == null || authentication.getName() == null) {
44+
// 이전에 발생했던 IllegalArgumentException은 그대로 유지합니다.
4045
throw new IllegalArgumentException("인증 정보가 없습니다.");
4146
}
47+
48+
String principalName = authentication.getName();
49+
4250
try {
43-
return Integer.parseInt(authentication.getName());
51+
return Integer.parseInt(principalName);
4452
} catch (NumberFormatException e) {
45-
throw new CustomException(ErrorCode.UNAUTHORIZED, "유효하지 않은 인증 정보입니다.");
53+
Member member = memberService.findByEmail(principalName)
54+
.orElseThrow(() -> new CustomException(ErrorCode.UNAUTHORIZED, "유효하지 않은 인증 정보입니다."));
55+
return member.getId();
4656
}
4757
}
4858

0 commit comments

Comments
 (0)