1
mirror of https://gitlab.com/commento/commento.git synced 2025-06-29 22:56:37 -04:00

api: add option to forbid new owner registrations

Closes https://gitlab.com/commento/commento-ce/issues/10
This commit is contained in:
Adhityaa Chandrasekar
2018-07-24 15:38:00 +05:30
parent 58be6a44b6
commit 9fb33fbd9d
3 changed files with 15 additions and 1 deletions

View File

@ -24,6 +24,8 @@ func configParse() error {
"CDN_PREFIX": "",
"FORBID_NEW_OWNERS": "false",
"STATIC": binPath,
"GZIP_STATIC": "false",
@ -53,7 +55,7 @@ func configParse() error {
}
// Mandatory config parameters
for _, env := range []string{"POSTGRES", "PORT", "ORIGIN"} {
for _, env := range []string{"POSTGRES", "PORT", "ORIGIN", "FORBID_NEW_OWNERS"} {
if os.Getenv(env) == "" {
logger.Errorf("missing COMMENTO_%s environment variable", env)
return errorMissingConfig
@ -64,6 +66,11 @@ func configParse() error {
os.Setenv("CDN_PREFIX", os.Getenv("ORIGIN"))
}
if os.Getenv("FORBID_NEW_OWNERS") != "true" && os.Getenv("FORBID_NEW_OWNERS") != "false" {
logger.Errorf("COMMENTO_FORBID_NEW_OWNERS neither 'true' nor 'false'")
return errorInvalidConfigValue
}
static := os.Getenv("STATIC")
for strings.HasSuffix(static, "/") {
static = static[0 : len(static)-1]