728x90
문제점 : 패스워드 리셋을 위해 본인인증 과정 중 빈칸 양식을 제출하면 500 error를 보이는 현상이 나타남.
해결 : 컨트롤러에 if 문으로 isEmpt를 이용한 예외 처리 진행
// PW 찾기 폼 진입
@GetMapping("passwordResetForm")
public String passwordResetForm() {
return "/account/passwordResetForm";
}
// PW 리셋 & 비밀번호 이메일 전송
@PostMapping("passwordReset")
public String passwordReset(String username, String email) {
if(username.isEmpty() || email.isEmpty()) {
return "redirect:/passwordResetForm?error=true";
} else if(memberService.compareEmailUsername(username, email)) {
String temporaryPassword = memberService.getRandomPassword(username);
mailService.sendMail(username, email, temporaryPassword);
return "redirect:/passwordResetForm?email=" + email;
} else {
return "redirect:/passwordResetForm?error=true";
}
}
'Web > SpringBoot' 카테고리의 다른 글
[Spring Boot] JavaMailSender로 메일 보내기 (0) | 2022.01.03 |
---|---|
[Spring Boot] Ajax(비동기) 통신으로 댓글 구현 (+ Jquery 사용법) (0) | 2022.01.02 |
[Spring Boot] 컨트롤러에서 redirect 경로 (0) | 2021.12.30 |
[Spring Boot] 페이징 ( + MyBatis, 타임리프) 및 타임리프 리스트 띄우기 (0) | 2021.12.28 |
[Spring Boot] Timestamp로 회원가입 시간 저장 (MySQL) (0) | 2021.12.22 |