Skip to content
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] 비밀번호 재설정 기능을 구현한다. #843

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

tkdgur0906
Copy link
Contributor

❗ Issue

✨ 구현한 기능

  • 이메일로 인증번호 전송
  • 인증번호 검증
  • 재설정된 비밀번호로 업데이트

📢 논의하고 싶은 내용

🎸 기타

LocalDateTime 테스트를 위해 Clock을 빈으로 등록했습니다.
yml파일 mail관련 설정 업데이트 예저입니다.

Copy link
Contributor

@shin-jisong shin-jisong left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~

@@ -30,12 +38,16 @@ public class AuthService {

private static final Logger log = LoggerFactory.getLogger(AuthService.class);
private static final int GUEST_USER_LIMIT = 1;
private static final int PASSWORD_RESET_CODE_EXPIRED_MINUTES = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

5분 혹은 10분이 적당하지 않을까요?!

}

userRepository.updatePasswordByEmail(
new Email(request.email()), new Password(request.newPassword()));
Copy link
Contributor

Choose a reason for hiding this comment

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

여기서 패스워드 리셋 코드 저장한 걸 삭제하는 건 어떨까요?!

Comment on lines +36 to +37
void updatePasswordByEmail(@Param("email") Email email, @Param("newPassword") Password newPassword);

Copy link
Contributor

Choose a reason for hiding this comment

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

로그인 타입도 지정해 줘야 될 것 같아요!

@Autowired
private PasswordResetCodeRepository passwordResetCodeRepository;

@DisplayName("특정 시간보다 나중에 생성된 비밀번호 초기화 코드 존재 시 참 반환")
Copy link
Contributor

Choose a reason for hiding this comment

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

컨벤션이랑 살짝 다른 것 같아서 확인해 주세요!

Copy link
Contributor

@tsulocalize tsulocalize left a comment

Choose a reason for hiding this comment

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

간단한 리뷰 남겨드렸습니다~

.hasMessage(ExceptionCode.AUTHENTICATION_PASSWORD_CODE_NOT_FOUND.getMessage());
}

@DisplayName("비밀번호 재설정 선공")
Copy link
Contributor

Choose a reason for hiding this comment

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

선공 -> 성공


class MailSenderTest {

@DisplayName("이메일 전송 시 send 메소드 호출")
Copy link
Contributor

Choose a reason for hiding this comment

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

  • 성공

Copy link
Contributor

@JINU-CHANG JINU-CHANG left a comment

Choose a reason for hiding this comment

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

수고많으셨어요~! 코멘트 몇가지 남겼습니다 🚀

Comment on lines +15 to +18
@Getter
@NoArgsConstructor(access = PROTECTED)
@Entity
public class PasswordResetCode extends BaseEntity {
Copy link
Contributor

Choose a reason for hiding this comment

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

일회성 데이터 같아서 DB에 저장할 필요는 없다고 생각되는데 혹시 다른 방식 고민해보신게 있나요??

Comment on lines +3 to +4
public record ConfirmPasswordResetCodeRequest(String email, String code) {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

요기는 Valid 필요없나요??

@@ -109,6 +121,31 @@ public void logout(String accessToken, String refreshToken, User user) {
validateTokenOwnership(user, accessAuthUser, refreshAuthUser);
}

public void sendPasswordResetEmail(ForgotPasswordRequest request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@transactional 빠진 것 같아요 👀

Comment on lines +48 to +50
private final MailSender mailSender;
private final PasswordResetCodeRepository passwordResetCodeRepository;
private final Clock clock;
Copy link
Contributor

Choose a reason for hiding this comment

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

비밀번호 찾기에 대한 코드량이 상당한 것 같은데 새로운 서비스로 분리해보는 건 어떨까요? 해당 클래스들이 의존성을 가질 수 있겠네요!


@Value("${spring.mail.properties.mail.smtp.debug}")
private boolean debug;

Copy link
Contributor

Choose a reason for hiding this comment

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

공백 👀

return ResponseEntity.noContent().build();
}

@PostMapping("/v1/password-reset/new-password")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@PostMapping("/v1/password-reset/new-password")
@PostMapping("/v1/password-reset")

마지막은 new-password 단어를 빼도 의미전달이 될 것 같은데 어떠신가용

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants