保誠-保戶業務員媒合平台
jack
2024-12-25 db15612798841319bafcb3ed4e77c7c013b9446f
pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java
@@ -34,7 +34,7 @@
@RestController
@RequestMapping("/api/eService")
public class EServiceResource {
   private final static Logger log = LoggerFactory.getLogger(EServiceResource.class);
@@ -47,31 +47,34 @@
    @Autowired
    ConsultantService consultantService;
    @Autowired
    AesUtil aesUtil;
    @AuditLoggingInject(type = CONSULTANT_LOGIN)
    @PostMapping("/authenticate/{imgCode}")
    public ResponseEntity<UserJWTController.JWTToken> authorize(
    public void authorize(
          @RequestBody EServiceLoginVM eServiceLoginVM
          , HttpServletResponse response, HttpServletRequest request,
         @PathVariable String imgCode){
       String paswword = AesUtil.aesDecode(eServiceLoginVM.getPassword());
         @PathVariable String imgCode) throws Exception{
       String paswword = aesUtil.aesDecode(eServiceLoginVM.getPassword());
       if(!StringUtils.hasText(paswword)) {
          throw new OtpLoginFailException("密碼解密失敗");
       }
       HttpSession session = request.getSession();
       String sessionImpCode = (String) session.getAttribute("img_code");
       if (!StringUtils.hasText(sessionImpCode)
            || !StringUtils.hasText(imgCode)) {
          throw new OtpLoginFailException("驗證碼輸入錯誤");
      }
       if(!imgCode.equals(sessionImpCode)) {
          throw new OtpLoginFailException("驗證碼輸入錯誤");
       }
       session.setAttribute("img_code", null);
       EServiceAuthenticationToken authenticationToken = new EServiceAuthenticationToken(
            eServiceLoginVM.getUsername(),
@@ -79,12 +82,6 @@
        );
        Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
        consultantService.updateLoginTime(eServiceLoginVM.getUsername());
        SecurityContextHolder.getContext().setAuthentication(authenticationToken);
        String jwt = tokenProvider.createToken(authentication, false);
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer" + jwt);
        return new ResponseEntity<>(new UserJWTController.JWTToken(jwt), httpHeaders, HttpStatus.OK);
        session.setAttribute("authentication", authentication);
    }
}