mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
Fix: Increase password max length and accept '-' for username in regex (#564)
* fix: increase username max length and accept '-' in regex * fix: increase username max length and accept '-' in regex * fix: increase username max length and accept '-' in regex
This commit is contained in:
parent
df2a68e1e7
commit
d2ce2ef2cd
6 changed files with 19 additions and 19 deletions
|
@ -25,7 +25,7 @@ const userSchema = mongoose.Schema(
|
||||||
type: String,
|
type: String,
|
||||||
lowercase: true,
|
lowercase: true,
|
||||||
required: [true, "can't be blank"],
|
required: [true, "can't be blank"],
|
||||||
match: [/^[a-zA-Z0-9_]+$/, 'is invalid'],
|
match: [/^[a-zA-Z0-9_-]+$/, 'is invalid'],
|
||||||
index: true
|
index: true
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
|
@ -45,7 +45,7 @@ const userSchema = mongoose.Schema(
|
||||||
type: String,
|
type: String,
|
||||||
trim: true,
|
trim: true,
|
||||||
minlength: 8,
|
minlength: 8,
|
||||||
maxlength: 60
|
maxlength: 128
|
||||||
},
|
},
|
||||||
avatar: {
|
avatar: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -162,9 +162,9 @@ module.exports.validateUser = (user) => {
|
||||||
username: Joi.string()
|
username: Joi.string()
|
||||||
.min(2)
|
.min(2)
|
||||||
.max(80)
|
.max(80)
|
||||||
.regex(/^[a-zA-Z0-9_]+$/)
|
.regex(/^[a-zA-Z0-9_-]+$/)
|
||||||
.required(),
|
.required(),
|
||||||
password: Joi.string().min(8).max(60).allow('').allow(null)
|
password: Joi.string().min(8).max(128).allow('').allow(null)
|
||||||
};
|
};
|
||||||
|
|
||||||
return schema.validate(user);
|
return schema.validate(user);
|
||||||
|
|
|
@ -77,7 +77,7 @@ Issuer.discover(process.env.OPENID_ISSUER)
|
||||||
email: userinfo.email || '',
|
email: userinfo.email || '',
|
||||||
emailVerified: userinfo.email_verified || false,
|
emailVerified: userinfo.email_verified || false,
|
||||||
name: fullName
|
name: fullName
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
user.provider = 'openid';
|
user.provider = 'openid';
|
||||||
user.openidId = userinfo.sub;
|
user.openidId = userinfo.sub;
|
||||||
|
|
|
@ -2,7 +2,7 @@ const Joi = require('joi');
|
||||||
|
|
||||||
const loginSchema = Joi.object().keys({
|
const loginSchema = Joi.object().keys({
|
||||||
email: Joi.string().trim().email().required(),
|
email: Joi.string().trim().email().required(),
|
||||||
password: Joi.string().trim().min(6).max(20).required()
|
password: Joi.string().trim().min(8).max(128).required()
|
||||||
});
|
});
|
||||||
|
|
||||||
const registerSchema = Joi.object().keys({
|
const registerSchema = Joi.object().keys({
|
||||||
|
@ -11,11 +11,11 @@ const registerSchema = Joi.object().keys({
|
||||||
.trim()
|
.trim()
|
||||||
.min(2)
|
.min(2)
|
||||||
.max(20)
|
.max(20)
|
||||||
.regex(/^[a-zA-Z0-9_]+$/)
|
.regex(/^[a-zA-Z0-9_-]+$/)
|
||||||
.required(),
|
.required(),
|
||||||
email: Joi.string().trim().email().required(),
|
email: Joi.string().trim().email().required(),
|
||||||
password: Joi.string().trim().min(6).max(20).required(),
|
password: Joi.string().trim().min(8).max(128).required(),
|
||||||
confirm_password: Joi.string().trim().min(6).max(20).required()
|
confirm_password: Joi.string().trim().min(8).max(128).required()
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -74,7 +74,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
|
||||||
},
|
},
|
||||||
maxLength: {
|
maxLength: {
|
||||||
value: 40,
|
value: 40,
|
||||||
message: 'Password must be less than 40 characters'
|
message: 'Password must be 128 characters or less'
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
aria-invalid={!!errors.password}
|
aria-invalid={!!errors.password}
|
||||||
|
|
|
@ -187,8 +187,8 @@ function Registration() {
|
||||||
message: 'Password must be at least 8 characters'
|
message: 'Password must be at least 8 characters'
|
||||||
},
|
},
|
||||||
maxLength: {
|
maxLength: {
|
||||||
value: 40,
|
value: 128,
|
||||||
message: 'Password must be less than 40 characters'
|
message: 'Password must be 128 characters or less'
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
aria-invalid={!!errors.password}
|
aria-invalid={!!errors.password}
|
||||||
|
@ -217,11 +217,11 @@ function Registration() {
|
||||||
id="confirm_password"
|
id="confirm_password"
|
||||||
data-testid="confirm_password"
|
data-testid="confirm_password"
|
||||||
aria-label="Confirm password"
|
aria-label="Confirm password"
|
||||||
// uncomment to prevent pasting in confirm field
|
// uncomment to block pasting in confirm field
|
||||||
onPaste={(e) => {
|
// onPaste={(e) => {
|
||||||
e.preventDefault();
|
// e.preventDefault();
|
||||||
return false;
|
// return false;
|
||||||
}}
|
// }}
|
||||||
{...register('confirm_password', {
|
{...register('confirm_password', {
|
||||||
validate: (value) => value === password || 'Passwords do not match'
|
validate: (value) => value === password || 'Passwords do not match'
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -94,8 +94,8 @@ function ResetPassword() {
|
||||||
message: 'Password must be at least 8 characters'
|
message: 'Password must be at least 8 characters'
|
||||||
},
|
},
|
||||||
maxLength: {
|
maxLength: {
|
||||||
value: 40,
|
value: 128,
|
||||||
message: 'Password must be less than 40 characters'
|
message: 'Password must be 128 characters or less'
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
aria-invalid={!!errors.password}
|
aria-invalid={!!errors.password}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue