mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-10 02:10:17 +08:00
Pass context to DeleteUser and AuthenticateUser
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package acl
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -134,7 +135,7 @@ func (acl *ACL) RegisterConnection(conn *net.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
func (acl *ACL) DeleteUser(usernames []string) error {
|
||||
func (acl *ACL) DeleteUser(ctx context.Context, usernames []string) error {
|
||||
var user User
|
||||
for _, username := range usernames {
|
||||
if username == "default" {
|
||||
@@ -165,7 +166,7 @@ func (acl *ACL) DeleteUser(usernames []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (acl *ACL) AuthenticateConnection(conn *net.Conn, cmd []string) error {
|
||||
func (acl *ACL) AuthenticateConnection(ctx context.Context, conn *net.Conn, cmd []string) error {
|
||||
var passwords []Password
|
||||
var user User
|
||||
|
||||
|
@@ -64,7 +64,7 @@ func (p Plugin) handleAuth(ctx context.Context, cmd []string, server utils.Serve
|
||||
if len(cmd) < 2 || len(cmd) > 3 {
|
||||
return nil, errors.New(utils.WRONG_ARGS_RESPONSE)
|
||||
}
|
||||
if err := p.acl.AuthenticateConnection(conn, cmd); err != nil {
|
||||
if err := p.acl.AuthenticateConnection(ctx, conn, cmd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []byte(utils.OK_RESPONSE), nil
|
||||
@@ -240,7 +240,7 @@ func (p Plugin) handleDelUser(ctx context.Context, cmd []string, server utils.Se
|
||||
if len(cmd) < 3 {
|
||||
return nil, errors.New(utils.WRONG_ARGS_RESPONSE)
|
||||
}
|
||||
if err := p.acl.DeleteUser(cmd[2:]); err != nil {
|
||||
if err := p.acl.DeleteUser(ctx, cmd[2:]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []byte(utils.OK_RESPONSE), nil
|
||||
|
Reference in New Issue
Block a user