Fix nil panic when tenantID is nil

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-03-20 15:36:46 +01:00
parent a44c90c966
commit ef8e62d488

View File

@@ -196,6 +196,10 @@ func graphqlHandler(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg
func (r *Resolver) GetTenantServiceIfAuthorized(ctx context.Context, tenantID gid.TenantID) *probo.TenantService {
tenantIDs, _ := ctx.Value(userTenantContextKey).(*[]gid.TenantID)
if tenantIDs == nil {
panic(fmt.Errorf("tenant not found"))
}
for _, id := range *tenantIDs {
if id == tenantID {
return r.proboSvc.WithTenant(tenantID)