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

@@ -3,6 +3,7 @@ package main
import (
"golang.org/x/crypto/bcrypt"
"net/http"
"os"
"time"
)
@@ -11,6 +12,10 @@ func ownerNew(email string, name string, password string) (string, error) {
return "", errorMissingField
}
if os.Getenv("FORBID_NEW_OWNERS") == "true" {
return "", errorNewOwnerForbidden
}
ownerHex, err := randomHex(32)
if err != nil {
logger.Errorf("cannot generate ownerHex: %v", err)