| | |
| | | import { http } from "./httpClient"; |
| | | import { AxiosResponse } from 'axios'; |
| | | import _ from "lodash"; |
| | | import CryptoJS from "crypto-js"; |
| | | import forge from "node-forge"; |
| | | import { http } from "./httpClient"; |
| | | // import CryptoJS from "asmcrypto-js"; |
| | | |
| | | import { ConsultantLoginInfo } from "../models/ConsultantLoginInfo"; |
| | |
| | | async sendOtp(loginInfo: LoginRequest, verifyCode: string): Promise<OtpInfo> { |
| | | try { |
| | | const response = await http.post(`/otp/sendOtp/${verifyCode}`, loginInfo); |
| | | if (response !== null) { |
| | | // 弱掃Test1: 改為 if (response) |
| | | if (response) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | |
| | | return http.get('/login/validate/get_img_code',{ responseType : 'arraybuffer' }) |
| | | .then( response => { |
| | | const toBase64 = window.btoa( |
| | | _.reduce( new Uint8Array(response.data),(data,byte) => |
| | | data + String.fromCharCode(byte),'') |
| | | Array.from(new Uint8Array(response.data)).reduce((data, byte) => |
| | | data + String.fromCharCode(byte), '') |
| | | ); |
| | | const imgSrc = `data:image/jpeg;base64,${toBase64}`; |
| | | return imgSrc; |