Skip to content

armgit / ente

Public Imported from GitHub
0

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

Don't apply auto-first-admin if internal.admin is set

Manav Rathif096e084efc0
diff --git a/server/pkg/middleware/auth.go b/server/pkg/middleware/auth.go
index 0b8fe5bd05..ec029e7629 100644
--- a/server/pkg/middleware/auth.go
+++ b/server/pkg/middleware/auth.go
@@ -93,17 +93,15 @@ func (m *AuthMiddleware) AdminAuthMiddleware() gin.HandlerFunc {
}
// The config allows alternatively specifying a singular admin ID to
// workaround Viper issues in passing env vars for an int slice.
- if len(admins) == 0 {
- admin := viper.GetInt("internal.admin")
- if admin != 0 {
+ admin := viper.GetInt("internal.admin")
+ if len(admins) == 0 && admin != 0 {
if int64(admin) == userID {
c.Next()
return
}
- }
}
// if no admins are set, then check if the user is first user in the system
- if len(admins) == 0 {
+ if len(admins) == 0 && admin == 0 {
id, err := m.UserAuthRepo.GetMinUserID()
if err != nil && id == userID {
c.Next()