Don't apply auto-first-admin if internal.admin is set
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user