From d39218d56f5d1c96667035e969d414aa8a2fb81e Mon Sep 17 00:00:00 2001
From: jack <jack.su@pollex.com.tw>
Date: 星期二, 08 八月 2023 17:20:37 +0800
Subject: [PATCH] [UPDATE] 更新前端aes加密密碼的實作

---
 PAMapp/shared/services/login.service.ts                            |   20 +++++++++++++++++---
 pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java |    1 +
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/PAMapp/shared/services/login.service.ts b/PAMapp/shared/services/login.service.ts
index 0c05281..7f7d9f7 100644
--- a/PAMapp/shared/services/login.service.ts
+++ b/PAMapp/shared/services/login.service.ts
@@ -1,7 +1,7 @@
 import { http } from "./httpClient";
 import { AxiosResponse } from 'axios';
 import _ from "lodash";
-import AES from 'crypto-js/aes';
+import CryptoJS from "crypto-js";
 
 import { ConsultantLoginInfo } from "../models/ConsultantLoginInfo";
 import { LoginRequest } from "../models/loginRequest.model";
@@ -85,8 +85,22 @@
 
   /** 憿批�� **/
   logInToConsultant(consultantDto:ConsultantLoginInfo, verificationCode: string):Promise<AxiosResponse<LoginSuccessToken>>{
-    const encryptPassword = AES.encrypt(consultantDto.password, 'PAM KEY').toString();
-    return http.post(`/eService/authenticate/${verificationCode}`, { ...consultantDto, password: encryptPassword });
+    // const encryptPassword = AES.encrypt(consultantDto.password, 'PAM KEY').toString();
+    const plaintext = "Hello, AES!";
+      const key = "PAMKEY1234567890";
+      const iv = "0123456789abcdef";
+
+      const keyBytes = CryptoJS.enc.Utf8.parse(key);
+      const ivBytes = CryptoJS.enc.Utf8.parse(iv);
+
+      const encrypted = CryptoJS.AES.encrypt(plaintext, keyBytes, {
+        iv: ivBytes,
+        mode: CryptoJS.mode.CBC,
+        padding: CryptoJS.pad.Pkcs7,
+      });
+
+      console.log("Encrypted Text:", encrypted.toString());
+    return http.post(`/eService/authenticate/${verificationCode}`, { ...consultantDto, password: encrypted.toString() });
   }
 }
 
diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java
index 796e2dd..b1aeb62 100644
--- a/pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java
+++ b/pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java
@@ -54,6 +54,7 @@
     		, HttpServletResponse response, HttpServletRequest request,
 			@PathVariable String imgCode){
     	
+    	
     	String paswword = AesUtil.aesDecode(eServiceLoginVM.getPassword());
     	if(!StringUtils.hasText(paswword)) {
     		throw new OtpLoginFailException("撖Ⅳ閫�撖仃���");

--
Gitblit v1.8.0