mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-10 10:20:08 +08:00
Replaces utils.Contains with slices.Contains in modules/acl/user.go
This commit is contained in:
@@ -2,6 +2,7 @@ package acl
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/kelvinmwinuka/memstore/src/utils"
|
"github.com/kelvinmwinuka/memstore/src/utils"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ type User struct {
|
|||||||
func (user *User) Normalise() {
|
func (user *User) Normalise() {
|
||||||
user.IncludedCategories = RemoveDuplicateEntries(user.IncludedCategories, "allCategories")
|
user.IncludedCategories = RemoveDuplicateEntries(user.IncludedCategories, "allCategories")
|
||||||
user.ExcludedCategories = RemoveDuplicateEntries(user.ExcludedCategories, "allCategories")
|
user.ExcludedCategories = RemoveDuplicateEntries(user.ExcludedCategories, "allCategories")
|
||||||
if utils.Contains(user.ExcludedCategories, "*") {
|
if slices.Contains(user.ExcludedCategories, "*") {
|
||||||
user.IncludedCategories = []string{}
|
user.IncludedCategories = []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ func (user *User) Normalise() {
|
|||||||
user.IncludedCommands = []string{"*"}
|
user.IncludedCommands = []string{"*"}
|
||||||
}
|
}
|
||||||
user.ExcludedCommands = RemoveDuplicateEntries(user.ExcludedCommands, "allCommands")
|
user.ExcludedCommands = RemoveDuplicateEntries(user.ExcludedCommands, "allCommands")
|
||||||
if utils.Contains(user.ExcludedCommands, "*") {
|
if slices.Contains(user.ExcludedCommands, "*") {
|
||||||
user.IncludedCommands = []string{}
|
user.IncludedCommands = []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ func (user *User) Normalise() {
|
|||||||
user.IncludedPubSubChannels = []string{"*"}
|
user.IncludedPubSubChannels = []string{"*"}
|
||||||
}
|
}
|
||||||
user.ExcludedPubSubChannels = RemoveDuplicateEntries(user.ExcludedPubSubChannels, "allChannels")
|
user.ExcludedPubSubChannels = RemoveDuplicateEntries(user.ExcludedPubSubChannels, "allChannels")
|
||||||
if utils.Contains(user.ExcludedPubSubChannels, "*") {
|
if slices.Contains(user.ExcludedPubSubChannels, "*") {
|
||||||
user.IncludedPubSubChannels = []string{}
|
user.IncludedPubSubChannels = []string{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,7 +184,7 @@ func (user *User) UpdateUser(cmd []string) error {
|
|||||||
user.IncludedCommands = []string{"*"}
|
user.IncludedCommands = []string{"*"}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(str) > 2 && !utils.Contains([]uint8{'&', '@'}, str[1]) {
|
if len(str) > 2 && !slices.Contains([]uint8{'&', '@'}, str[1]) {
|
||||||
if str[0] == '+' {
|
if str[0] == '+' {
|
||||||
user.IncludedCommands = append(user.IncludedCommands, str[1:])
|
user.IncludedCommands = append(user.IncludedCommands, str[1:])
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user