From bdcaac32492b5e6223fef4304f4d86403e877022 Mon Sep 17 00:00:00 2001 From: Jack <jack.su@pollex.com.tw> Date: 星期五, 26 十一月 2021 18:33:11 +0800 Subject: [PATCH] [UPDATE] 調整註冊和OTP登入的流程 --- pamapi/src/main/java/com/pollex/pam/service/CustomerService.java | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/service/CustomerService.java b/pamapi/src/main/java/com/pollex/pam/service/CustomerService.java index 2fd1590..fe9a396 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/CustomerService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/CustomerService.java @@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import com.pollex.pam.domain.Customer; import com.pollex.pam.domain.OtpTmp; @@ -15,6 +16,7 @@ import com.pollex.pam.service.mapper.CustomerDTOMapper; @Service +@Transactional public class CustomerService { @Autowired @@ -33,7 +35,7 @@ return customerRepository.save(customer); } - public String registerCustomer(CustomerRegisterDTO registDTO) { + public Customer registerCustomer(CustomerRegisterDTO registDTO) { boolean isCustomerExist = checkCustomerExist(registDTO); if(isCustomerExist) { throw new UsernameAlreadyUsedException(); @@ -45,10 +47,11 @@ if(otpTmp.getStatus() == OtpTmpStatusEnum.VERRIFIED) { Customer customer = customerDTOMapper.toCustomer(registDTO); save(customer); - String jwt = customerAuthService.authorize(account, registDTO.getIndexKey(), registDTO.getOtpCode()); - return jwt; + return customer; }else { - throw new UsernameNotFoundException("Otp record not found"); + throw new IllegalArgumentException("Invalid indexKey state error. IndexKey: " + + registDTO.getIndexKey() + + " => status: " + otpTmp.getStatus()); } } -- Gitblit v1.8.0