Make Match() with empty list not return a positive result
Now that we use Match() in allowAdmin() as well, it's awkward to have it return `true` when called with an empty admin list. No admins defined was taken to mean "everyone is an admin". We can either have a `len(users) == 0` check in `allowAdmin` which rejects the request, or we can change `Match()` so that it doesn't return positive responses when called with an empty list. Doing the latter sounds better. It's more natural that matching against an empty list will yield "no match".
This commit is contained in:
@@ -13,8 +13,10 @@ func (b *Bot) allowAnyone(actorID id.UserID, targetRoomID id.RoomID) bool {
|
||||
}
|
||||
|
||||
func (b *Bot) allowOwner(actorID id.UserID, targetRoomID id.RoomID) bool {
|
||||
if !utils.Match(actorID.String(), b.allowedUsers) {
|
||||
return false
|
||||
if len(b.allowedUsers) != 0 {
|
||||
if !utils.Match(actorID.String(), b.allowedUsers) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if b.noowner {
|
||||
|
||||
Reference in New Issue
Block a user