-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] 일반 로그인을 구현한다. #775
[BE] 일반 로그인을 구현한다. #775
Conversation
# Conflicts: # backend/bang-ggood/src/main/java/com/bang_ggood/auth/controller/AuthController.java # backend/bang-ggood/src/main/java/com/bang_ggood/checklist/controller/ChecklistController.java # backend/bang-ggood/src/main/java/com/bang_ggood/global/config/WebMvcConfig.java # backend/bang-ggood/src/test/java/com/bang_ggood/AcceptanceTest.java # backend/bang-ggood/src/test/java/com/bang_ggood/auth/JwtTokenFixture.java # backend/bang-ggood/src/test/java/com/bang_ggood/auth/controller/cookie/CookieResolverTest.java # backend/bang-ggood/src/test/java/com/bang_ggood/auth/service/AuthServiceTest.java # backend/bang-ggood/src/test/java/com/bang_ggood/station/service/SubwayStationServiceTest.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
시소 고생많으셨습니다 👍
전반적으로 잘 작성해주셔서 사소한 코멘트 몇가지만 남겨보았어요!
|
||
@Transactional | ||
public AuthTokenResponse login(OauthLoginRequest request) { | ||
public AuthTokenResponse authLogin(OauthLoginRequest request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public AuthTokenResponse authLogin(OauthLoginRequest request) { | |
public AuthTokenResponse outhLogin(OauthLoginRequest request) { |
User user = userRepository.findByEmailAndLoginType(oauthInfoApiResponse.kakao_account().email(), | ||
LoginType.KAKAO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 함께 변경해주셨네요
return AuthTokenResponse.of(accessToken, refreshToken); | ||
} | ||
|
||
private void checkPassword(LocalLoginRequestV1 request, User user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private void checkPassword(LocalLoginRequestV1 request, User user) { | |
private void validatePassword(LocalLoginRequestV1 request, User user) { |
지금까지는 검증 메서드를 validate라고 했던 것 같아서 제안드려봅니다~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 부분은 정책에 따라 규칙에 맞는가 확인하는 것이 아닌 맞는가 체크하는 부분이라 생각해서 validate 명명보다는 비즈니스 로직 명명을 가질 수 있도록 구현하였습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 이해한 바에 따르면, 단순히 비밀번호가 다른지 체크하는 부분은 정책적인 부분이 아니라 네이밍을 다르게 가져가고 싶다는 의미로 이해했어요! 하지만 null, empty 체크도 비슷한 경우라고 생각되는데 validate 메서드명을 사용했던 것 같아서 이 부분은 어떻게 생각하는지 궁금합니다 ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null 혹은 empty 체크는 값 자체의 형식에 대한 검증이라 생각해요!
validate 검증 로직은 주로 입력 데이터가 특정 형식, 패턴 또는 규칙에 부합하는지 확인 등 비즈니스 로직을 시작하기 직전에 값을 선별하는 데 사용하는 명명에 가깝다고 생각해요
예를 들어 저장한다는 비즈니스 로직 전 해당 값을 저장하기에 유효한지 검증하는 validate 검증 로직을 작성하는 것처럼요 🤔
반면에 비밀번호 일치 여부를 확인하는 로직은 단순히 입력 데이터의 형식 검증이 아닌, 기존 데이터와 비교하여 중요한 비즈니스 결정을 내리는 과정이라 생각했어요!
validate라는 검증의 의미만 담기에는 다소 의미가 축소되는 느낌이 있다고 판단하였습니다
private final PasswordEncoder passwordEncoder; | ||
private final UserRepository userRepository; | ||
|
||
private static void validateTokenOwnership(User user, AuthUser accessAuthUser, AuthUser refreshAuthUser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위로 올라온 이유가 있나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
머지하다가 그렇게 됐네요.... 다시 내려두었습니다 🔽
@@ -100,23 +132,23 @@ void login_default_checklist_question() { | |||
assertThat(sum).isEqualTo(Question.findDefaultQuestions().size()); | |||
} | |||
|
|||
@DisplayName("로그인 성공 : 회원 가입시 디폴트 체크리스트 추가") | |||
@DisplayName("카카오 로그인 성공 : 회원 가입시 디폴트 체크리스트를 추가한다.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
컨벤션이 명사구 형태여서 저번 PR에서 수정했던 기억이 있는데 다시 문장형으로 수정하신 이유가 있나요?-?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 머지하다가... 충돌 해결한다고... 🥲
수정해 두었습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생많으셨습니다!
충돌 해결된 후에 한번더 볼게요!
@@ -51,6 +54,10 @@ public User(Long id, String name, String email) { // TODO 테스트용 | |||
this.email = email; | |||
} | |||
|
|||
public boolean isDifferentPassword(String password) { | |||
return !Objects.equals(this.password, password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if both arguments are null, true is returned.
password
가 둘 다 null
이면 true
가 반환되는데, 의도되었나요 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로직이 바뀌었습니다!
# Conflicts: # backend/bang-ggood/src/main/java/com/bang_ggood/auth/service/AuthService.java # backend/bang-ggood/src/main/java/com/bang_ggood/auth/service/PasswordEncoder.java # backend/bang-ggood/src/main/java/com/bang_ggood/global/DBInitializer.java # backend/bang-ggood/src/main/java/com/bang_ggood/global/exception/ExceptionCode.java # backend/bang-ggood/src/main/java/com/bang_ggood/user/domain/User.java # backend/bang-ggood/src/main/java/com/bang_ggood/user/repository/UserRepository.java # backend/bang-ggood/src/main/resources/data.sql # backend/bang-ggood/src/test/java/com/bang_ggood/auth/service/AuthServiceTest.java # backend/bang-ggood/src/test/java/com/bang_ggood/user/UserFixture.java # backend/bang-ggood/src/test/resources/data-test.sql # backend/bang-ggood/src/test/resources/schema-test.sql
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잘 수정해주셨네요 고생많으셨어요!!
간단한 코멘트 남겼으니 확인 부탁드립니다~
private PasswordEncoder() { | ||
private static byte[] extractSaltByPassword(String encodedPassword) { | ||
String[] parts = encodedPassword.split(DELIMITER); | ||
if (parts.length != 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2도 상수 분리하는 것은 어떤가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PASSWORD_AND_SALT_LENGTH
로 상수화하였습니다!
@@ -25,11 +25,20 @@ public class Password { | |||
private String value; | |||
|
|||
public Password(String value) { | |||
if (value == null || value.isEmpty()) { | |||
this.value = value; | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
비밀번호가 비어있어도 null로 들어가야하지 않나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
각 입력값을 그대로 넣어 주는 것이 좋을 것 같아서 해당 로직으로 작성했습니다
다만 isEmpty에 해당할 경우가 빈 문자열인 "" 에 해당할 것 같은데 null을 넣는 것이 더욱 명확한 코드 전달일 것 같아 null을 넣는 것으로 대체하였습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Password라는 도메인이 null 허용이라는 게 null로 로그인 가능하다? 는 느낌이 들었어요.
개인적인 의견이지만 exception을 던지면 좋을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영하였습니다~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
짱짱 고생많으셨습니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨어요~
간단한 코멘트만 확인하고 바로 approve 할게요!
@@ -25,11 +25,20 @@ public class Password { | |||
private String value; | |||
|
|||
public Password(String value) { | |||
if (value == null || value.isEmpty()) { | |||
this.value = value; | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Password라는 도메인이 null 허용이라는 게 null로 로그인 가능하다? 는 느낌이 들었어요.
개인적인 의견이지만 exception을 던지면 좋을 것 같아요!
❗ Issue
✨ 구현한 기능
📢 논의하고 싶은 내용
먼저 머지되고 관련 내용 합쳐야 될 것 같습니다 🥲
🎸 기타