feat(user): store users in Postgres with password hashes

This commit is contained in:
kk10
2026-10-04 22:49:42 +03:00
parent bbcde1e95e
commit 527c1748f8
4 changed files with 70 additions and 20 deletions
+8 -1
View File
@@ -14,6 +14,7 @@ var usernamePattern = regexp.MustCompile(`^[a-z0-9_]{3,32}$`)
type CreateUserRequest struct {
Username string `json:"username"`
DisplayName string `json:"display_name"`
Password string `json:"password"`
}
type UserResponse struct {
@@ -29,7 +30,13 @@ func (r CreateUserRequest) Validate() bool {
}
displayNameLength := utf8.RuneCountInString(r.DisplayName)
if strings.TrimSpace(r.DisplayName) == "" || displayNameLength > 100 {
if strings.TrimSpace(r.DisplayName) == "" ||
displayNameLength > 100 ||
strings.ContainsRune(r.DisplayName, 0) {
return false
}
if n := utf8.RuneCountInString(r.Password); n < 12 || n > 128 {
return false
}