mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
🔐 feat: Add Configurable Min. Password Length (#9315)
- Added support for a minimum password length defined by the MIN_PASSWORD_LENGTH environment variable. - Updated login, registration, and reset password forms to utilize the configured minimum length. - Enhanced validation schemas to reflect the new minimum password length requirement. - Included tests to ensure the minimum password length functionality works as expected.
This commit is contained in:
parent
ea3b671182
commit
ba424666f8
8 changed files with 87 additions and 9 deletions
|
|
@ -125,7 +125,10 @@ const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error,
|
|||
aria-label={localize('com_auth_password')}
|
||||
{...register('password', {
|
||||
required: localize('com_auth_password_required'),
|
||||
minLength: { value: 8, message: localize('com_auth_password_min_length') },
|
||||
minLength: {
|
||||
value: startupConfig?.minPasswordLength || 8,
|
||||
message: localize('com_auth_password_min_length'),
|
||||
},
|
||||
maxLength: { value: 128, message: localize('com_auth_password_max_length') },
|
||||
})}
|
||||
aria-invalid={!!errors.password}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ const Registration: React.FC = () => {
|
|||
{renderInput('password', 'com_auth_password', 'password', {
|
||||
required: localize('com_auth_password_required'),
|
||||
minLength: {
|
||||
value: 8,
|
||||
value: startupConfig?.minPasswordLength || 8,
|
||||
message: localize('com_auth_password_min_length'),
|
||||
},
|
||||
maxLength: {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function ResetPassword() {
|
|||
const [params] = useSearchParams();
|
||||
const password = watch('password');
|
||||
const resetPassword = useResetPasswordMutation();
|
||||
const { setError, setHeaderText } = useOutletContext<TLoginLayoutContext>();
|
||||
const { setError, setHeaderText, startupConfig } = useOutletContext<TLoginLayoutContext>();
|
||||
|
||||
const onSubmit = (data: TResetPassword) => {
|
||||
resetPassword.mutate(data, {
|
||||
|
|
@ -83,7 +83,7 @@ function ResetPassword() {
|
|||
{...register('password', {
|
||||
required: localize('com_auth_password_required'),
|
||||
minLength: {
|
||||
value: 8,
|
||||
value: startupConfig?.minPasswordLength || 8,
|
||||
message: localize('com_auth_password_min_length'),
|
||||
},
|
||||
maxLength: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue