From 911650ccd306eeb61429567a989e177e6699762c Mon Sep 17 00:00:00 2001 From: Maxime Bouillot Date: Wed, 20 Jul 2022 19:06:33 +0100 Subject: [PATCH] Applied changed suggested by Ishan. This conserns some boolean logic, wording, and YAML config. Co-authored-by: Ishan Goel --- Admin's Manual.md | 4 ++-- config.go | 2 +- main.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Admin's Manual.md b/Admin's Manual.md index a47c1ea4..8042d194 100644 --- a/Admin's Manual.md +++ b/Admin's Manual.md @@ -144,6 +144,6 @@ whitelist: The `whitelist` entry is a map similar to the `admins` map. The keys are the ID of the allowed user and the value are a string whose content is not used. -If someone is in the `admins` list, it is assumed that they are allowed. They, they would not be rejected from a private server even if their ID is not in the `whitelist` list. -If everyone on the private server is an admin, you don't need to have a `whitelist` list as all the ID are already in the `admin` list. +All admins are allowed even if their ID is not in the whitelist. +Therefore, if everyone on the private server is an admin, a whitelist isn't necessary. diff --git a/config.go b/config.go index b554224d..a54083cf 100644 --- a/config.go +++ b/config.go @@ -17,7 +17,7 @@ type ConfigType struct { Admins map[string]string `yaml:"admins"` Censor bool `yaml:"censor,omitempty"` Private bool `yaml:"private,omitempty"` - WhiteList map[string]string `yaml:"whitelist"` + WhiteList map[string]string `yaml:"whitelist,omitempty"` IntegrationConfig string `yaml:"integration_config"` } diff --git a/main.go b/main.go index 03db8195..781b8759 100644 --- a/main.go +++ b/main.go @@ -327,7 +327,7 @@ func newUser(s ssh.Session) *User { if Config.Private { _, okWhitelist := Config.WhiteList[u.id] _, okAdmin := Config.Admins[u.id] - if !okAdmin && !okWhitelist { + if !(okAdmin || okWhitelist) { fmt.Println("Refusing user with ID ", u.id) u.writeln(Devbot, "You are not allowed to log into this private server. If this is a mistake, send your id ("+u.id+") to the admin so that they can whitelist you.") u.closeQuietly()