From 9a66e817f7d202345d9b2520e85f6363a3124a34 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期三, 09 八月 2023 08:19:05 +0800
Subject: [PATCH] Update: [顧問登入] AES 加密 with 參數: 刪除重複的 import library

---
 PAMapp/shared/services/login.service.ts |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/PAMapp/shared/services/login.service.ts b/PAMapp/shared/services/login.service.ts
index d90ed46..293a4a4 100644
--- a/PAMapp/shared/services/login.service.ts
+++ b/PAMapp/shared/services/login.service.ts
@@ -1,6 +1,7 @@
 import { http } from "./httpClient";
 import { AxiosResponse } from 'axios';
 import _ from "lodash";
+import CryptoJS from "crypto-js";
 
 import { ConsultantLoginInfo } from "../models/ConsultantLoginInfo";
 import { LoginRequest } from "../models/loginRequest.model";
@@ -84,8 +85,23 @@
 
   /** 憿批�� **/
   logInToConsultant(consultantDto:ConsultantLoginInfo, verificationCode: string):Promise<AxiosResponse<LoginSuccessToken>>{
-    return http.post(`/eService/authenticate/${verificationCode}`,consultantDto);
+
+      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(consultantDto.password, keyBytes, {
+        iv: ivBytes,
+        mode: CryptoJS.mode.CBC,
+        padding: CryptoJS.pad.Pkcs7,
+      });
+
+    return http.post(`/eService/authenticate/${verificationCode}`, { ...consultantDto, password: encrypted.toString() });
   }
+
+
 }
 
 export default new LoginService();

--
Gitblit v1.9.3