add internal.disable-registration to config

This commit is contained in:
Julian Pollinger
2024-11-29 00:44:33 +01:00
parent 74117db8b0
commit 39f2d03e74
2 changed files with 10 additions and 3 deletions

View File

@@ -321,6 +321,9 @@ internal:
# the "admin" instead of "admins". This can be useful e.g. when wishing to
# pass the admin as an environment variable.
admin:
# If set to true, users will not be able to register a new account.
# Account creation will fail when entering the email ott
disable-registration: false
# Replication config
#

View File

@@ -362,9 +362,13 @@ func (c *UserController) onVerificationSuccess(context *gin.Context, email strin
userID, err := c.UserRepo.GetUserIDWithEmail(email)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
userID, _, err = c.createUser(email, source)
if err != nil {
return ente.EmailAuthorizationResponse{}, stacktrace.Propagate(err, "")
if !viper.GetBool("internal.disable-registration") {
userID, _, err = c.createUser(email, source)
if err != nil {
return ente.EmailAuthorizationResponse{}, stacktrace.Propagate(err, "")
}
} else {
return ente.EmailAuthorizationResponse{}, stacktrace.Propagate(ente.ErrPermissionDenied, "")
}
} else {
return ente.EmailAuthorizationResponse{}, stacktrace.Propagate(err, "")