fix: password check (#4497)

* fix: password check

* add doc

* fix: password check
This commit is contained in:
Archer
2025-04-10 11:49:35 +08:00
committed by GitHub
parent 199f454b6b
commit ec3bcfa124
8 changed files with 144 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ import { useTranslation } from 'next-i18next';
import { useForm } from 'react-hook-form';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { updatePasswordByOld } from '@/web/support/user/api';
import { PasswordRule } from '@/web/support/user/login/constants';
import { checkPasswordRule } from '@/web/support/user/login/constants';
import { useToast } from '@fastgpt/web/hooks/useToast';
type FormType = {
@@ -70,9 +70,11 @@ const UpdatePswModal = ({ onClose }: { onClose: () => void }) => {
placeholder={t('account_info:password_tip')}
{...register('newPsw', {
required: true,
pattern: {
value: PasswordRule,
message: t('account_info:password_tip')
validate: (val) => {
if (!checkPasswordRule(val)) {
return t('login:password_tip');
}
return true;
}
})}
></Input>

View File

@@ -1,7 +1,7 @@
import React, { Dispatch } from 'react';
import { FormControl, Box, Input, Button } from '@chakra-ui/react';
import { useForm } from 'react-hook-form';
import { LoginPageTypeEnum, PasswordRule } from '@/web/support/user/login/constants';
import { LoginPageTypeEnum, checkPasswordRule } from '@/web/support/user/login/constants';
import { postFindPassword } from '@/web/support/user/api';
import { useSendCode } from '@/web/support/user/hooks/useSendCode';
import type { ResLogin } from '@/global/support/api/userRes.d';
@@ -138,9 +138,11 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
placeholder={t('login:password_tip')}
{...register('password', {
required: true,
pattern: {
value: PasswordRule,
message: t('login:password_tip')
validate: (val) => {
if (!checkPasswordRule(val)) {
return t('login:password_tip');
}
return true;
}
})}
></Input>

View File

@@ -1,7 +1,7 @@
import React, { Dispatch } from 'react';
import { FormControl, Box, Input, Button } from '@chakra-ui/react';
import { useForm } from 'react-hook-form';
import { LoginPageTypeEnum, PasswordRule } from '@/web/support/user/login/constants';
import { LoginPageTypeEnum, checkPasswordRule } from '@/web/support/user/login/constants';
import { postRegister } from '@/web/support/user/api';
import { useSendCode } from '@/web/support/user/hooks/useSendCode';
import type { ResLogin } from '@/global/support/api/userRes';
@@ -166,9 +166,11 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
placeholder={t('login:password_tip')}
{...register('password', {
required: true,
pattern: {
value: PasswordRule,
message: t('login:password_tip')
validate: (val) => {
if (!checkPasswordRule(val)) {
return t('login:password_tip');
}
return true;
}
})}
></Input>