From 9580111fa4bbea4871d86a2b917fb248682b1b30 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期一, 29 十一月 2021 12:02:36 +0800 Subject: [PATCH] [ADD]【todo 131166】新增客戶個人帳號資訊API,又因應會有更新機制,故不把手機及email資訊放在detail中 --- pamapi/src/main/java/com/pollex/pam/service/CustomerAuthService.java | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/service/CustomerAuthService.java b/pamapi/src/main/java/com/pollex/pam/service/CustomerAuthService.java index aa9b5b4..04f116a 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/CustomerAuthService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/CustomerAuthService.java @@ -25,16 +25,16 @@ @Service @Transactional public class CustomerAuthService { - + @Autowired AuthenticationManagerBuilder authenticationManagerBuilder; - + @Autowired CustomerRepository customerRepository; @Autowired TokenProvider tokenProvider; - + public String authorize(Customer account, String indexKey, String otpCode) { OtpAccount otpAccount = OtpAccount.createOtpAccount(account, indexKey); OtpAuthenticationToken authenticationToken = new OtpAuthenticationToken( @@ -43,26 +43,25 @@ ); SecurityContextHolder.getContext().setAuthentication(authenticationToken); - + Authentication authentication = buildCustomerAuthToken(account, otpCode, indexKey); String jwt = tokenProvider.createToken(authentication, false); return jwt; } - + public UsernamePasswordAuthenticationToken buildCustomerAuthToken(Customer customer , String otpCode, String indexKey) { - + List<GrantedAuthority> grantedAuths = Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); - + final String account = customer.toAccountString(); - UsernamePasswordAuthenticationToken authenticationToken = + UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(account, otpCode, grantedAuths); Map<String, String> details = new HashMap<>(); details.put(CustomerDetailEnum.ID.getValue(), customer.getId().toString()); details.put(CustomerDetailEnum.NAME.getValue(), customer.getName()); - details.put(CustomerDetailEnum.ACCOUNT.getValue(), account); -// details.put(CustomerDetailEnum.CONTACT_TYPE.getValue(), customer.getContactType()); + authenticationToken.setDetails(details); return authenticationToken; -- Gitblit v1.8.0