Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.Base64;
import java.util.Map;

import static ssu.eatssu.global.handler.response.BaseResponseStatus.INVALID_IDENTITY_TOKEN;
import static ssu.eatssu.global.handler.response.BaseResponseStatus.*;

Choose a reason for hiding this comment

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

medium

리포지토리 스타일 가이드에 따라 와일드카드(*)를 사용한 import는 지양해야 합니다. 사용되는 모든 클래스를 명시적으로 import 해주세요.

Suggested change
import static ssu.eatssu.global.handler.response.BaseResponseStatus.*;
import static ssu.eatssu.global.handler.response.BaseResponseStatus.INVALID_IDENTITY_TOKEN;
import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_EMAIL;
import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_PROVIDER_ID;
References
  1. 리포지토리 스타일 가이드 3번 규칙은 라이브러리를 import할 때 와일드카드 사용을 금지하고 있습니다. (link)


@Component
@RequiredArgsConstructor
Expand All @@ -49,10 +49,19 @@ private OAuthInfo getOAuthInfoByPublicKey(String identityToken, PublicKey public
.parseClaimsJws(identityToken)
.getBody();

//Claims 에서 email, providerId(사용자 식별값) 를 추출한다.
Object emailObj = claims.get("email");
Object providerIdObj = claims.get("sub");

if (providerIdObj == null) {
throw new BaseException(NOT_FOUND_PROVIDER_ID);
}
if (emailObj == null) {
throw new BaseException(NOT_FOUND_EMAIL);
}

try {
String email = claims.get("email").toString();
String providerId = claims.get("sub").toString();
String email = emailObj.toString();
String providerId = providerIdObj.toString();
return new OAuthInfo(email, providerId);
} catch (ExpiredJwtException exception) {
throw new BaseException(INVALID_IDENTITY_TOKEN);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/ssu/eatssu/domain/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public class User extends BaseTimeEntity {
private Long id;
@Enumerated(EnumType.STRING)
private Role role;
@Column(unique = true)
private String email;
private String nickname;
@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public enum BaseResponseStatus {
NOT_FOUND_PARTNERSHIP(false, HttpStatus.NOT_FOUND, 40410, "해당 제휴를 찾을 수 없습니다."),
NOT_FOUND_PARTNERSHIP_RESTAURANT(false, HttpStatus.NOT_FOUND, 40411, "해당 제휴 식당을 찾을 수 없습니다."),
INVALID_NICKNAME(false, HttpStatus.NOT_FOUND, 40412, "잘못된 닉네임입니다."),
NOT_FOUND_PROVIDER_ID(false, HttpStatus.NOT_FOUND, 40413, "Claims에서 ProviderId(sub)를 찾을 수 없습니다."),
NOT_FOUND_EMAIL(false, HttpStatus.NOT_FOUND, 40414, "Claims에서 이메일을 찾을 수 없습니다."),

/**
* 405 METHOD_NOT_ALLOWED 지원하지 않은 method 호출
Expand Down