-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: dev
Are you sure you want to change the base?
Conversation
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.
수고하셨습니다~
@@ -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; |
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.
5분 혹은 10분이 적당하지 않을까요?!
} | ||
|
||
userRepository.updatePasswordByEmail( | ||
new Email(request.email()), new Password(request.newPassword())); |
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.
여기서 패스워드 리셋 코드 저장한 걸 삭제하는 건 어떨까요?!
void updatePasswordByEmail(@Param("email") Email email, @Param("newPassword") Password newPassword); | ||
|
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.
로그인 타입도 지정해 줘야 될 것 같아요!
@Autowired | ||
private PasswordResetCodeRepository passwordResetCodeRepository; | ||
|
||
@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.
컨벤션이랑 살짝 다른 것 같아서 확인해 주세요!
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.
간단한 리뷰 남겨드렸습니다~
.hasMessage(ExceptionCode.AUTHENTICATION_PASSWORD_CODE_NOT_FOUND.getMessage()); | ||
} | ||
|
||
@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.
선공 -> 성공
|
||
class MailSenderTest { | ||
|
||
@DisplayName("이메일 전송 시 send 메소드 호출") |
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.
수고많으셨어요~! 코멘트 몇가지 남겼습니다 🚀
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
@Entity | ||
public class PasswordResetCode extends BaseEntity { |
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.
일회성 데이터 같아서 DB에 저장할 필요는 없다고 생각되는데 혹시 다른 방식 고민해보신게 있나요??
public record ConfirmPasswordResetCodeRequest(String email, String code) { | ||
} |
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.
요기는 Valid 필요없나요??
@@ -109,6 +121,31 @@ public void logout(String accessToken, String refreshToken, User user) { | |||
validateTokenOwnership(user, accessAuthUser, refreshAuthUser); | |||
} | |||
|
|||
public void sendPasswordResetEmail(ForgotPasswordRequest 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.
@transactional 빠진 것 같아요 👀
private final MailSender mailSender; | ||
private final PasswordResetCodeRepository passwordResetCodeRepository; | ||
private final Clock clock; |
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.
비밀번호 찾기에 대한 코드량이 상당한 것 같은데 새로운 서비스로 분리해보는 건 어떨까요? 해당 클래스들이 의존성을 가질 수 있겠네요!
|
||
@Value("${spring.mail.properties.mail.smtp.debug}") | ||
private boolean debug; | ||
|
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 ResponseEntity.noContent().build(); | ||
} | ||
|
||
@PostMapping("/v1/password-reset/new-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.
@PostMapping("/v1/password-reset/new-password") | |
@PostMapping("/v1/password-reset") |
마지막은 new-password 단어를 빼도 의미전달이 될 것 같은데 어떠신가용
❗ Issue
✨ 구현한 기능
📢 논의하고 싶은 내용
🎸 기타
LocalDateTime 테스트를 위해 Clock을 빈으로 등록했습니다.
yml파일 mail관련 설정 업데이트 예저입니다.