Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server] Skip sending ott during signup when registrations are disabled (#4563)

Neeraj Guptaa1e97239c355
diff --git a/server/configurations/local.yaml b/server/configurations/local.yaml
index f39fbcc283..cd061cfd06 100644
--- a/server/configurations/local.yaml
+++ b/server/configurations/local.yaml
@@ -331,10 +331,8 @@ internal:
admin:
# If set to true, users will not be able to register a new account.
#
- # Account creation will fail when entering the email ott. This doesn't
- # affect the clients, users can still go through the registration flow, but
- # when entering the ott they received via mail, they will get an
- # unauthorized error and thus cannot create new accounts.
+ # During sign up, the client will get an unauthorized error and
+ # thus cannot create new accounts.
disable-registration: false
# Replication config
diff --git a/server/pkg/controller/user/userauth.go b/server/pkg/controller/user/userauth.go
index 6721903518..86828d1cee 100644
--- a/server/pkg/controller/user/userauth.go
+++ b/server/pkg/controller/user/userauth.go
@@ -93,6 +93,9 @@ func (c *UserController) SendEmailOTT(context *gin.Context, email string, purpos
if isComplete && purpose == ente.SignUpOTTPurpose {
return stacktrace.Propagate(ente.ErrUserAlreadyRegistered, "user has already completed sign up process")
}
+ if purpose == ente.SignUpOTTPurpose && viper.GetBool("internal.disable-registration") {
+ return stacktrace.Propagate(ente.ErrPermissionDenied, "registration is disabled")
+ }
if !isComplete && purpose == ente.LoginOTTPurpose {
return stacktrace.Propagate(ente.ErrUserNotRegistered, "user has not completed sign up process")
}
@@ -362,6 +365,7 @@ func (c *UserController) onVerificationSuccess(context *gin.Context, email strin
userID, err := c.UserRepo.GetUserIDWithEmail(email)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
+ // Keep this check as users can still trigger ott via other means that can lead to this code path
if viper.GetBool("internal.disable-registration") {
return ente.EmailAuthorizationResponse{}, stacktrace.Propagate(ente.ErrPermissionDenied, "")
} else {