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

This commit is contained in:
Manav Rathi
2024-11-28 16:04:04 +05:30
parent 2196c3dbc8
commit f096e084ef

View File

@@ -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()