Fix code that didn't even compile

This commit is contained in:
Manav Rathi
2024-11-28 15:50:26 +05:30
parent c6872d2d35
commit 2196c3dbc8

View File

@@ -94,9 +94,12 @@ 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 {
if viper.GetInt("internal.admin") == userId {
c.Next()
return
admin := viper.GetInt("internal.admin")
if 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