작성
·
297
0
안녕하세요 강사님
(강사님 강좌는 3번째 보고 있습니다.)
AccountController.sendEmailLoginLink 에서
model.addAttribute("error", "유효한 이메일 주소가 아닙니다.");
return "account/email-login";
대신 아래를
attributes.addFlashAttribute("error", "유효한..);
return "redirect:/email-login";
사용해야 하는 것 아닌지요?
@PostMapping("/email-login")
public String sendEmailLoginLink(String email, Model model, RedirectAttributes attributes) {
Account account = accountRepository.findByEmail(email);
if (account == null) {
model.addAttribute("error", "유효한 이메일 주소가 아닙니다.");
return "account/email-login";
}
if (!account.canSendConfirmEmail()) {
model.addAttribute("error", "이메일 로그인은 1시간 뒤에 사용할 수 있습니다.");
return "account/email-login";
}
accountService.sendLoginLink(account);
attributes.addFlashAttribute("message", "이메일 인증 메일을 발송했습니다.");
return "redirect:/email-login";
}
답변