mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Validate username length using rune count for accurate character measurement
This commit is contained in:
@@ -65,7 +65,8 @@ func CreateUser(username, password, cfToken string) (model.UserViewWithToken, er
|
|||||||
if !config.AllowRegister() {
|
if !config.AllowRegister() {
|
||||||
return model.UserViewWithToken{}, model.NewRequestError("User registration is not allowed")
|
return model.UserViewWithToken{}, model.NewRequestError("User registration is not allowed")
|
||||||
}
|
}
|
||||||
if len(username) < 3 || len(username) > 20 {
|
usernameLen := len([]rune(username))
|
||||||
|
if usernameLen < 3 || usernameLen > 20 {
|
||||||
return model.UserViewWithToken{}, model.NewRequestError("Username must be between 3 and 20 characters")
|
return model.UserViewWithToken{}, model.NewRequestError("Username must be between 3 and 20 characters")
|
||||||
}
|
}
|
||||||
if len(password) < 6 || len(password) > 20 {
|
if len(password) < 6 || len(password) > 20 {
|
||||||
|
Reference in New Issue
Block a user