• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

AccountController.sendEmailLoginLink 문의

22.10.15 21:28 작성 조회수 211

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";
}

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!