Преглед изворни кода

add audio for captcha

web_access_fix
Alex Cheung пре 1 месец
родитељ
комит
f3f75f97c6
2 измењених фајлова са 32 додато и 2 уклоњено
  1. +16
    -1
      src/pages/authentication/auth-forms/BusCustomFormWizard.js
  2. +16
    -1
      src/pages/authentication/auth-forms/IAmSmartFormWizard.js

+ 16
- 1
src/pages/authentication/auth-forms/BusCustomFormWizard.js Прегледај датотеку

@@ -30,7 +30,7 @@ import * as yup from 'yup';
import { strengthColorChi, strengthIndicator } from 'utils/password-strength'; import { strengthColorChi, strengthIndicator } from 'utils/password-strength';
// import {apiPath} from "auth/utils"; // import {apiPath} from "auth/utils";
import axios from "axios"; import axios from "axios";
import { POST_PUBLIC_USER_REGISTER, POST_CAPTCHA, POST_USERNAME, POST_USER_EMAIL } from "utils/ApiPathConst";
import { POST_PUBLIC_USER_REGISTER, POST_CAPTCHA, POST_USERNAME, POST_USER_EMAIL, POST_CAPTCHA_AUDIO } from "utils/ApiPathConst";
// import * as HttpUtils from 'utils/HttpUtils'; // import * as HttpUtils from 'utils/HttpUtils';
import * as ComboData from "utils/ComboData"; import * as ComboData from "utils/ComboData";


@@ -118,6 +118,16 @@ const BusCustomFormWizard = (props) => {
changePassword(''); changePassword('');
}, []); }, []);


const playCaptchaAudio = async () => {
const resp = await axios.post(`${POST_CAPTCHA_AUDIO}`,
{ base64Url, lang: intl.locale },
{ responseType: "arraybuffer" }
);
const blob = new Blob([resp.data], { type: "audio/wav" });
const url = URL.createObjectURL(blob);
new Audio(url).play();
};

const handleCheckUsername = async () => { const handleCheckUsername = async () => {
if (values?.username) { if (values?.username) {
const response = await axios.post(`${POST_USERNAME}`, { const response = await axios.post(`${POST_USERNAME}`, {
@@ -1538,6 +1548,11 @@ const BusCustomFormWizard = (props) => {
{formik.errors.captchaField} {formik.errors.captchaField}
</FormHelperText> </FormHelperText>
)} )}
<Stack spacing={1} direction="row">
<Button onClick={playCaptchaAudio} aria-label={intl.formatMessage({id:"captchaPlayAudioAria"})}>
<FormattedMessage id="captchaPlayAudio" />
</Button>
</Stack>
</Stack> </Stack>
</Grid> </Grid>
</Grid> </Grid>


+ 16
- 1
src/pages/authentication/auth-forms/IAmSmartFormWizard.js Прегледај датотеку

@@ -21,7 +21,7 @@ import { useFormik, FormikProvider } from 'formik';
import * as yup from 'yup'; import * as yup from 'yup';


import axios from "axios"; import axios from "axios";
import { POST_IAMSMART_USER_REGISTER, POST_CAPTCHA, POST_USER_EMAIL } from "utils/ApiPathConst";
import { POST_IAMSMART_USER_REGISTER, POST_CAPTCHA, POST_USER_EMAIL, POST_CAPTCHA_AUDIO } from "utils/ApiPathConst";


import * as ComboData from "utils/ComboData"; import * as ComboData from "utils/ComboData";


@@ -79,6 +79,16 @@ const CustomFormWizard = (props) => {
const [base64Url, setBase64Url] = useState("") const [base64Url, setBase64Url] = useState("")
const [checkCode, setCheckCode] = useState("") const [checkCode, setCheckCode] = useState("")


const playCaptchaAudio = async () => {
const resp = await axios.post(`${POST_CAPTCHA_AUDIO}`,
{ base64Url, lang: intl.locale },
{ responseType: "arraybuffer" }
);
const blob = new Blob([resp.data], { type: "audio/wav" });
const url = URL.createObjectURL(blob);
new Audio(url).play();
};

useEffect(() => { useEffect(() => {
location.state?.responseData ?? window.location.assign("/login"); location.state?.responseData ?? window.location.assign("/login");
if (captchaImg == "") if (captchaImg == "")
@@ -1067,6 +1077,11 @@ const CustomFormWizard = (props) => {
{formik.errors.captchaField} {formik.errors.captchaField}
</FormHelperText> </FormHelperText>
)} )}
<Stack spacing={1} direction="row">
<Button onClick={playCaptchaAudio} aria-label={intl.formatMessage({id:"captchaPlayAudioAria"})}>
<FormattedMessage id="captchaPlayAudio" />
</Button>
</Stack>
</Stack> </Stack>
</Grid> </Grid>
</Grid> </Grid>


Loading…
Откажи
Сачувај