feat(user): store users in Postgres with password hashes
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user