티스토리 뷰
- MemberController
@RequestMapping(value = "recoverPasswordEmail",
method = RequestMethod.GET,
produces = MediaType.TEXT_HTML_VALUE)
@ResponseBody
public ModelAndView getRecoverPasswordEmail(EmailAuthEntity emailAuth) {
Enum<?> result = this.memberService.recoverPasswordAuth(emailAuth);
ModelAndView modelAndView = new ModelAndView("member/recoverPasswordEmail");
modelAndView.addObject("result", result.name());
return modelAndView;
}
- MemberService
public Enum<? extends IResult> recoverPasswordAuth(EmailAuthEntity emailAuth) {
EmailAuthEntity existingEmailAuth = this.memberMapper.selectEmailAuthByEmailCodeSalt(
emailAuth.getEmail(),
emailAuth.getCode(),
emailAuth.getSalt());
if (existingEmailAuth== null) {
return CommonResult.FAILURE;
}
if (new Date().compareTo(existingEmailAuth.getExpiresOn()) > 0) {
return CommonResult.FAILURE;
}
existingEmailAuth.setExpired(true);
if(this.memberMapper.updateEmailAuth(existingEmailAuth) == 0) {
return CommonResult.FAILURE;
}
return CommonResult.SUCCESS;
}
- recoverPasswordEmail.html
<!doctype html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>스터디 - 이메일 인증</title>
<!--/*@thymesVar id="equals" type="java.lang.String"*/-->
<script th:if="${result != null && result.equals('SUCCESS')}">
alert('이메일 인증이 완료되었습니다.\n\n비밀번호 재설정 페이지로 돌아가 계속해 주세요.');
window.close();
</script>
<script th:if="${result == null && !result.equals('SUCCESS')}">
alert('이메일 인증에 실패하였습니다.\n\n인증 링크가 만료되었거나 일시적인 문제일 수 있습니다.');
window.close();
</script>
</head>
<body>
</body>
</html>


'웹 개발 > SpringBoot' 카테고리의 다른 글
| [Spring Boot] 로그인 구현 (2) | 2022.11.10 |
|---|---|
| [Spring Boot] Password Reset(2) (3) | 2022.11.09 |
| [Spring Boot] 비밀번호 재 설정 시 이메일 존재 유무 확인 (5) | 2022.11.08 |
| [Spring Boot] 공통된 내용을 util 경로로 이동한 암호화 (2) | 2022.11.08 |
| [Spring Boot] 회원 가입 구현하기 문제 (0) | 2022.11.08 |
댓글