Skip to content

Commit

Permalink
Force lower case for user names
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoe committed May 24, 2024
1 parent 6efe78d commit 2286b19
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/users/user_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"slices"
"strings"

"golang.org/x/exp/maps"

Expand Down Expand Up @@ -57,19 +58,21 @@ func (m *UserManager) Users() map[string]*User {

// User returns a copy of a user.
func (m *UserManager) User(name string) (*User, error) {
return m.onChangeMap.Get(util.ComparableString(name))
return m.onChangeMap.Get(util.ComparableString(strings.ToLower(name)))
}

// AddUser adds a user to the user manager.
func (m *UserManager) AddUser(user *User) error {
user.Permissions = m.SanitizePermissions(user.Permissions)
user.Name = strings.ToLower(user.Name)

return m.onChangeMap.Add(user)
}

// ModifyUser modifies a user in the user manager.
func (m *UserManager) ModifyUser(user *User) error {
user.Permissions = m.SanitizePermissions(user.Permissions)
user.Name = strings.ToLower(user.Name)

_, err := m.onChangeMap.Modify(user.ID(), func(item *User) bool {
*item = *user
Expand Down

0 comments on commit 2286b19

Please sign in to comment.