mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
fix(registration): Make Username optional (#831)
* fix(User.js): update validation schema for username field, allow empty string as a valid value fix(validators.js): update validation schema for username field, allow empty string as a valid value fix(Registration.tsx, validators.js): update validation rules for name and username fields, change minimum length to 2 and maximum length to 80, assure they match and allow empty string as a valid value fix(Eng.tsx): update localization string for com_auth_username, indicate that it is optional * fix(User.js): update regex pattern for username validation to allow special characters @#$%&*() fix(validators.js): update regex pattern for username validation to allow special characters @#$%&*() * fix(Registration.spec.tsx): fix validation error message for username length requirement
This commit is contained in:
parent
d38e463d34
commit
37347d4683
5 changed files with 15 additions and 16 deletions
|
|
@ -24,9 +24,7 @@ const userSchema = mongoose.Schema(
|
|||
username: {
|
||||
type: String,
|
||||
lowercase: true,
|
||||
required: [true, 'can\'t be blank'],
|
||||
match: [/^[a-zA-Z0-9_.-]+$/, 'is invalid'],
|
||||
index: true,
|
||||
default: '',
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
|
|
@ -173,12 +171,13 @@ module.exports.validateUser = (user) => {
|
|||
});
|
||||
const schema = {
|
||||
avatar: Joi.any(),
|
||||
name: Joi.string().min(2).max(80).required(),
|
||||
name: Joi.string().min(3).max(80).required(),
|
||||
username: Joi.string()
|
||||
.trim()
|
||||
.allow('')
|
||||
.min(2)
|
||||
.max(80)
|
||||
.regex(/^[a-zA-Z0-9_.-]+$/)
|
||||
.required(),
|
||||
.regex(/^[a-zA-Z0-9_.-@#$%&*() ]+$/),
|
||||
password: Joi.string().min(8).max(128).allow('').allow(null),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue