Fix nil panic when tenantID is nil
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -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 {
|
func (r *Resolver) GetTenantServiceIfAuthorized(ctx context.Context, tenantID gid.TenantID) *probo.TenantService {
|
||||||
tenantIDs, _ := ctx.Value(userTenantContextKey).(*[]gid.TenantID)
|
tenantIDs, _ := ctx.Value(userTenantContextKey).(*[]gid.TenantID)
|
||||||
|
|
||||||
|
if tenantIDs == nil {
|
||||||
|
panic(fmt.Errorf("tenant not found"))
|
||||||
|
}
|
||||||
|
|
||||||
for _, id := range *tenantIDs {
|
for _, id := range *tenantIDs {
|
||||||
if id == tenantID {
|
if id == tenantID {
|
||||||
return r.proboSvc.WithTenant(tenantID)
|
return r.proboSvc.WithTenant(tenantID)
|
||||||
|
|||||||
Reference in New Issue
Block a user