mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Improve username validation logic.
This commit is contained in:
@@ -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")
|
||||
|
Reference in New Issue
Block a user