Improve username validation logic.

This commit is contained in:
2025-06-12 15:06:42 +08:00
parent 41c40fa6d0
commit 0b3b54a0c4

View File

@@ -11,7 +11,6 @@ import (
"nysoure/server/utils"
"os"
"strconv"
"strings"
"sync"
"time"
"unicode"
@@ -377,9 +376,6 @@ func validateUsername(username string) error {
if usernameLen < 3 || usernameLen > 20 {
return model.NewRequestError("Username must be between 3 and 20 characters")
}
if strings.Contains(username, " ") {
return model.NewRequestError("Username cannot contain spaces")
}
for _, r := range []rune(username) {
if r == ' ' || r == '\n' || r == '\r' || r == '\t' || r == '\v' || r == '\f' {
return model.NewRequestError("Username cannot contain whitespace characters")