go-duck-cli 1.1.36 → 1.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -316,7 +316,11 @@ func TenantServerInterceptor(conf *config.Config, db *gorm.DB) middleware.Middle
316
316
  db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE LOWER(role_name) IN ? AND tenant_id = ?", lowerRoles, requestedTenant).Scan(&mappings)
317
317
  }
318
318
  } else {
319
- db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE LOWER(role_name) IN ?", lowerRoles).Scan(&mappings)
319
+ if isAdmin {
320
+ db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles").Scan(&mappings)
321
+ } else {
322
+ db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE LOWER(role_name) IN ?", lowerRoles).Scan(&mappings)
323
+ }
320
324
  }
321
325
 
322
326
  siloConnections := make(map[string]*gorm.DB)
@@ -179,7 +179,11 @@ func TenantMiddleware(db *gorm.DB, cfg *config.Config) gin.HandlerFunc {
179
179
  db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE LOWER(role_name) IN ? AND tenant_id IN ?", lowerRoles, requestedTenants).Scan(&mappings)
180
180
  }
181
181
  } else {
182
- db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE LOWER(role_name) IN ?", lowerRoles).Scan(&mappings)
182
+ if isAdmin {
183
+ db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles").Scan(&mappings)
184
+ } else {
185
+ db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE LOWER(role_name) IN ?", lowerRoles).Scan(&mappings)
186
+ }
183
187
  }
184
188
 
185
189
  // Filter out unauthorized mappings (e.g. admin_db for non-admins)
@@ -299,6 +303,8 @@ func PublicTenantMiddleware(db *gorm.DB, cfg *config.Config) gin.HandlerFunc {
299
303
  var mappings []models.TenantRole
300
304
  if len(requestedTenants) > 0 {
301
305
  db.Raw("SELECT db_name, is_primary FROM tenant_roles WHERE tenant_id IN ?", requestedTenants).Scan(&mappings)
306
+ } else {
307
+ db.Raw("SELECT db_name, is_primary FROM tenant_roles ORDER BY is_primary DESC, id ASC LIMIT 1").Scan(&mappings)
302
308
  }
303
309
 
304
310
  dbName := fallbackDB
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-duck-cli",
3
- "version": "1.1.36",
3
+ "version": "1.1.37",
4
4
  "description": "The Ultimate Evolutionary Go Microservice Scaffolder.",
5
5
  "main": "index.js",
6
6
  "type": "module",