Allow using username as identifier
This commit is contained in:
@@ -51,9 +51,16 @@ func (s *MemoryStore) UpdateUser(u users.User) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *MemoryStore) GetUser(id string) (users.User, error) {
|
||||
u, ok := s.Users[id]
|
||||
func (s *MemoryStore) GetUser(identifier string) (users.User, error) {
|
||||
u, ok := s.Users[identifier]
|
||||
if !ok {
|
||||
// Check if identifier is username
|
||||
for _, u := range s.Users {
|
||||
if u.Username == identifier {
|
||||
return u, nil
|
||||
}
|
||||
}
|
||||
|
||||
return u, ErrNoSuchUser
|
||||
}
|
||||
|
||||
|
@@ -6,5 +6,5 @@ type UserStore interface {
|
||||
AddUser(users.User) error
|
||||
DeleteUser(id string) error
|
||||
UpdateUser(users.User) error
|
||||
GetUser(id string) (users.User, error)
|
||||
GetUser(identifier string) (users.User, error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user