Package com.easydesk.web.controller
Class ForgotPasswordController
java.lang.Object
com.easydesk.web.controller.ForgotPasswordController
'비밀번호 찾기' 흐름 전체를 담당하는 컨트롤러.
1) GET/POST /forgot-password : 이메일 입력 -> 해당 User를 email로 찾아서(EMAIL 컬럼에
unique 제약은 없어서 여러 명이 겹치면 첫 번째만 사용 - 데모 한계) 1회성 토큰을 발급하고,
그 토큰이 담긴 링크를 메일로 발송한다.
2) GET /reset-password?token=... : 토큰이 유효하면 새 비밀번호 입력 화면을 보여준다.
3) POST /reset-password : 토큰을 다시 검증하고, UserManager#forcePassword(User, String)로
실제 비밀번호를 반영한 뒤 토큰을 폐기한다.
보안 참고: 이 데모는 "해당 이메일로 가입된 사용자가 없습니다" 라는 에러를 그대로 보여준다
(계정 존재 여부를 감추는 게 목적인 서비스라면 이메일 발송 성공 여부와 무관하게 항상 같은
메시지를 보여주는 편이 낫다 - 지금 이 앱의 다른 화면들(로그인 등)도 이미 "존재하지 않는
사용자입니다" 식으로 명시적인 에러를 보여주는 스타일이라 그 관례를 따랐다).
화면 권한: reset-password 화면은 Screen 으로 따로 등록되어 있지 않다. 미등록 화면은 로그인이 필요한
화면으로 취급되는데, 비밀번호 재설정은 로그인할 수 없는 사용자가 메일 링크로 들어오는 흐름이라
forgot-password 와 같은 "ForgotPassword" 화면(공개)에 묶어 두었다.
-
Constructor Summary
ConstructorsConstructorDescriptionForgotPasswordController(SecurityService moduleSecurityService, org.springframework.context.MessageSource messageSource, PasswordResetTokenService tokenService, PasswordResetMailService mailService) -
Method Summary
Modifier and TypeMethodDescriptionform()resetSubmit(ResetPasswordForm form, org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) submit(ForgotPasswordForm form, org.springframework.ui.Model model, HttpServletRequest request)
-
Constructor Details
-
ForgotPasswordController
public ForgotPasswordController(@Qualifier("moduleSecurityService") SecurityService moduleSecurityService, org.springframework.context.MessageSource messageSource, PasswordResetTokenService tokenService, PasswordResetMailService mailService)
-
-
Method Details
-
form
-
submit
@PostMapping("/forgot-password") public String submit(@ModelAttribute("ForgotPasswordForm") ForgotPasswordForm form, org.springframework.ui.Model model, HttpServletRequest request) -
resetForm
-
resetSubmit
@PostMapping("/reset-password") public String resetSubmit(@ModelAttribute("ResetPasswordForm") ResetPasswordForm form, org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
-