| | |
| | | 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"; |
| | |
| | | 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 **/ |
| | |
| | | |
| | | /** 顧問登入 **/ |
| | | 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, |
| | | }); |
| | | |
| | | console.log("Encrypted Text:", encrypted.toString()); |
| | | |
| | | return http.post(`/eService/authenticate/${verificationCode}`, { ...consultantDto, password: encrypted.toString() }); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | export default new LoginService(); |