Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #173 from Strong-Potato/feature/#167-my-info-and-s…
Browse files Browse the repository at this point in the history
…pace-errors

[Feat] 마이페이지에 필요한 데이터 응답형식 변경
  • Loading branch information
Dr-KoKo authored Jan 24, 2024
2 parents 291da6f + 6c7e681 commit 2feb462
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

public record MyInfoResponse(
String nickname,
String email,
String profile,
AuthProvider provider
) {
public static MyInfoResponse from(MemberQuery.MemberResponse memberResponse) {
return new MyInfoResponse(memberResponse.nickname(), memberResponse.profile(), memberResponse.provider());
return new MyInfoResponse(memberResponse.nickname(), memberResponse.email(), memberResponse.profile(), memberResponse.provider());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public record MySpace(
String title,
LocalDate startDate,
LocalDate endDate,
String city,
String thumbnail,
List<SpaceResponse.MemberInfo> members,
Long dueDate
) {
public static MySpace from(SpaceResponse spaceResponse) {
Expand All @@ -29,6 +32,9 @@ public static MySpace from(SpaceResponse spaceResponse) {
spaceResponse.title(),
spaceResponse.startDate(),
spaceResponse.endDate(),
spaceResponse.city(),
spaceResponse.thumbnail(),
spaceResponse.members(),
spaceResponse.startDate() != null ?
ChronoUnit.DAYS.between(LocalDate.now(), spaceResponse.startDate()) : null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public ResponseEntity handleException(AccessDeniedException ex, WebRequest reque
public ResponseEntity handleException(AuthenticationException ex, WebRequest request) {
HttpStatus httpStatus = HttpStatus.UNAUTHORIZED;
String errorMessage = "Authentication Failed";
Integer responseCode = null;
if (ex instanceof OAuth2AuthenticationException exception) {
log.warn("[OAUTH_AUTHENTICATION_EXCEPTION] OAUTH_AUTHENTICATION FAILED : {}", exception.getMessage(), exception.getCause());
errorMessage = exception.getMessage();
Expand All @@ -49,10 +50,12 @@ public ResponseEntity handleException(AuthenticationException ex, WebRequest req
switch (exception) {
case UsernameNotFoundException usernameNotFoundException -> {
httpStatus = HttpStatus.OK;
responseCode = 401;
errorMessage = "회원가입되지 않은 이메일입니다.";
}
case BadCredentialsException badCredentialsException -> {
httpStatus = HttpStatus.OK;
responseCode = 401;
errorMessage = "이메일 또는 비밀번호를 확인해주세요.";
}
case InsufficientAuthenticationException insufficientAuthenticationException -> {
Expand All @@ -64,6 +67,7 @@ public ResponseEntity handleException(AuthenticationException ex, WebRequest req
}
ProblemDetail problemDetail = createProblemDetail(ex, httpStatus, errorMessage, null, null, request);
problemDetail.setType(type);
problemDetail.setProperty("responseCode", responseCode);
return handleExceptionInternal(ex, problemDetail, new HttpHeaders(), httpStatus, request);
}

Expand Down

0 comments on commit 2feb462

Please sign in to comment.