feat: add captcha (#2613)

* feat: captcha

* add borderRadius

* code perf
This commit is contained in:
papapatrick
2024-09-05 11:46:51 +08:00
committed by GitHub
parent d6233cd7b1
commit 3bcc3430fb
9 changed files with 215 additions and 93 deletions

View File

@@ -15,6 +15,7 @@ export const sendAuthCode = (data: {
username: string;
type: `${UserAuthTypeEnum}`;
googleToken: string;
captcha: string;
}) => POST(`/proApi/support/user/inform/sendAuthCode`, data);
export const getTokenLogin = () =>
@@ -82,3 +83,8 @@ export const getWXLoginQR = () =>
export const getWXLoginResult = (code: string) =>
GET<ResLogin>(`/proApi/support/user/account/login/wx/getResult`, { code });
export const getCaptchaPic = (username: string) =>
GET<{
captchaImage: string;
}>('/proApi/support/user/account/captcha', { username });

View File

@@ -12,10 +12,18 @@ export const useSendCode = () => {
const [codeCountDown, setCodeCountDown] = useState(0);
const { runAsync: sendCode, loading: codeSending } = useRequest2(
async ({ username, type }: { username: string; type: `${UserAuthTypeEnum}` }) => {
async ({
username,
type,
captcha
}: {
username: string;
type: `${UserAuthTypeEnum}`;
captcha: string;
}) => {
if (codeCountDown > 0) return;
const googleToken = await getClientToken(feConfigs.googleClientVerKey);
await sendAuthCode({ username, type, googleToken });
await sendAuthCode({ username, type, googleToken, captcha });
setCodeCountDown(60);
timer = setInterval(() => {