// AccountService login method
public LoginResponse login(LoginRequest loginRequest) {
Account account = accountRepository.findByEmail(loginRequest.email());
if(!passwordEncoder.matches(loginRequest.password(), account.password())){
// todo: 비밀번호 불일치 예외 처리
throw new IllegalArgumentException("Password is not matched");
}
if(account.isEmailVerified()){
userService.findUserByAccountId(account.id());
}
return new LoginResponse(
account.email(), account.phoneNumber(), null
);
}
// Account Record
public record Account (Long accountId, String email, String password, String phoneNumber, boolean isEmailVerified, boolean isActive) {
public Account(String email, String password, String phoneNumber) {
this(null, email, password, phoneNumber, false, true);
}
}
댓글남기기