mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-29 09:00:44 +02:00
[#961] updated min username length and added tests
This commit is contained in:
parent
01814067b1
commit
b1c7a012c5
@ -397,7 +397,7 @@ func (form *RecordUpsert) Validate() error {
|
||||
&form.Username,
|
||||
// require only on update, because on create we fallback to auto generated username
|
||||
validation.When(!form.record.IsNew(), validation.Required),
|
||||
validation.Length(4, 100),
|
||||
validation.Length(3, 100),
|
||||
validation.Match(usernameRegex),
|
||||
validation.By(form.checkUniqueUsername),
|
||||
),
|
||||
|
@ -694,6 +694,41 @@ func TestRecordUpsertAuthRecord(t *testing.T) {
|
||||
false,
|
||||
},
|
||||
|
||||
// username
|
||||
{
|
||||
"invalid username characters",
|
||||
"",
|
||||
map[string]any{
|
||||
"username": "test abc!@#",
|
||||
"password": "12345678",
|
||||
"passwordConfirm": "12345678",
|
||||
},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"invalid username length (less than 3)",
|
||||
"",
|
||||
map[string]any{
|
||||
"username": "ab",
|
||||
"password": "12345678",
|
||||
"passwordConfirm": "12345678",
|
||||
},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"invalid username length (more than 100)",
|
||||
"",
|
||||
map[string]any{
|
||||
"username": strings.Repeat("a", 101),
|
||||
"password": "12345678",
|
||||
"passwordConfirm": "12345678",
|
||||
},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
|
||||
// verified
|
||||
{
|
||||
"try to set verified without managed access",
|
||||
|
Loading…
x
Reference in New Issue
Block a user