Use reference for User instead of copying values in Connection type

This commit is contained in:
Kelvin Clement Mwinuka
2023-12-19 05:21:28 +08:00
parent f4432a4d0e
commit 5b2a0c1375
2 changed files with 221 additions and 60 deletions

View File

@@ -75,9 +75,8 @@ func (p Plugin) handleGetUser(ctx context.Context, cmd []string, server utils.Se
return nil, errors.New(utils.WRONG_ARGS_RESPONSE)
}
var user User
var user *User
userFound := false
for _, u := range p.acl.Users {
if u.Username == cmd[2] {
user = u
@@ -233,7 +232,10 @@ func (p Plugin) handleUsers(ctx context.Context, cmd []string, server utils.Serv
}
func (p Plugin) handleSetUser(ctx context.Context, cmd []string, server utils.Server) ([]byte, error) {
return nil, errors.New("ACL SETUSER not implemented")
if err := p.acl.SetUser(ctx, cmd[2:]); err != nil {
return nil, err
}
return []byte(utils.OK_RESPONSE), nil
}
func (p Plugin) handleDelUser(ctx context.Context, cmd []string, server utils.Server) ([]byte, error) {