메일 다시 보내기 클릭시 에러가 발생했다.
http://localhost:8002/resend-confirm-email
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed May 25 00:08:26 KST 2022
There was an unexpected error (type=Internal Server Error, status=500).
Cannot invoke "java.time.LocalDateTime.isBefore(java.time.chrono.ChronoLocalDateTime)" because "this.emailCheckTokenGeneratedAt" is null
java.lang.NullPointerException: Cannot invoke "java.time.LocalDateTime.isBefore(java.time.chrono.ChronoLocalDateTime)" because "this.emailCheckTokenGeneratedAt" is null
at com.familyevents.entity.Account.canSendConfirmEmail(Account.java:58)
at com.familyevents.account.AccountController.resendConfirmEmail(AccountController.java:92)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
강의로 배운 jpa말고 mysql로 임의로 바꾸는 과정에서 실수했다.
generateEmailCheckToken함수의 사용위치와 sql문에 파라미터를 누락해서 DB에 저장 되지 않는 실수가 있었다.
public Account processNewAccount(SignUpForm signUpForm) {
Account newAccount = saveNewAccount(signUpForm);
// newAccount.generateEmailCheckToken(); //UUID
sendSignUpConfirmEmail(newAccount);
return newAccount;
}
class AccountSQL {
public String createAccount(@Param("SignUpForm") Account account) {
return new SQL() {{
INSERT_INTO("ACCOUNT")
VALUES("EMAIL, NICKNAME, PASSWORD, JOINEDAT",
"#{SignUpForm.email}, #{SignUpForm.nickname}, #{SignUpForm.password}, NOW()")
}}
}
==>
private Account saveNewAccount(@Valid SignUpForm signUpForm) {
Account account = Account.builder()
.email(signUpForm.getEmail())
.nickname(signUpForm.getNickname())
.password(passwordEncoder.encode(signUpForm.getPassword()))
.build();
account.generateEmailCheckToken(); // UUID
accountRepository.createAccount(account);
return accountRepository.findByEmail(signUpForm.getEmail());
}
class AccountSQL {
public String createAccount(@Param("SignUpForm") Account account) {
return new SQL() {{
INSERT_INTO("ACCOUNT")
VALUES("EMAIL, NICKNAME, PASSWORD, EMAILCHECKTOKEN, JOINEDAT, EMAILCHECKTOKENGENERATEDAT",
"#{SignUpForm.email}, #{SignUpForm.nickname}, #{SignUpForm.password}, " +
"#{SignUpForm.emailCheckToken}, NOW(), #{SignUpForm.emailCheckTokenGeneratedAt}")
}}
}
잘 저장되는 모습
'프로젝트 정리 > 경조사 가계부 프로젝트' 카테고리의 다른 글
10. 회원가입 토큰 DB적용 (0) | 2022.06.01 |
---|---|
9. 회원가입 토큰 인증 (0) | 2022.05.28 |
7. SpringSecurity persistent_login 에러 (0) | 2022.05.23 |
#6 회원가입 로직 구현시 에러 해결 (0) | 2022.05.09 |
#4 회원가입 기능 구현하기 (구상) (0) | 2022.01.28 |