保誠-保戶業務員媒合平台
Tomas
2023-08-08 481521f9a75789c6df42e81d46118989d33bebb4
PAMapp/shared/services/login.service.ts
@@ -9,6 +9,7 @@
import { LoginVerify } from "../models/loginVerify.model";
import { OtpInfo } from "../models/otpInfo.model";
import { RegisterInfo } from "../models/registerInfo";
import CryptoJS from "crypto-js";
class LoginService {
    /** 顧客登入-發送OTP **/
@@ -85,9 +86,17 @@
  /** 顧問登入 **/
  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 plaintext = consultantDto.password;
    const key = "PAM KEY";
    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 });
    return http.post(`/eService/authenticate/${verificationCode}`, { ...consultantDto, password: encrypted.toString() });
  }
}
export default new LoginService();