Skip to content

Commit

Permalink
Merge pull request #3414 from iotaledger/fix_user_manager
Browse files Browse the repository at this point in the history
Force lower case for user names
  • Loading branch information
jorgemmsilva authored May 28, 2024
2 parents 3a2638b + 2286b19 commit eca19c7
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 eca19c7

Please sign in to comment.