fix create outlet
This commit is contained in:
parent
3826a6b7a9
commit
80a78137a0
@ -2,6 +2,7 @@ package appcontext
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -77,5 +78,18 @@ func FromContext(ctx context.Context) *ContextInfo {
|
||||
if info, ok := ctx.Value(ctxKey).(*ContextInfo); ok {
|
||||
return info
|
||||
}
|
||||
return nil
|
||||
// Fallback: construct ContextInfo from individual context values
|
||||
return &ContextInfo{
|
||||
CorrelationID: value(ctx, CorrelationIDKey),
|
||||
UserID: uuidValue(ctx, UserIDKey),
|
||||
OutletID: uuidValue(ctx, OutletIDKey),
|
||||
OrganizationID: uuidValue(ctx, OrganizationIDKey),
|
||||
AppVersion: value(ctx, AppVersionKey),
|
||||
AppID: value(ctx, AppIDKey),
|
||||
AppType: value(ctx, AppTypeKey),
|
||||
Platform: value(ctx, PlatformKey),
|
||||
DeviceOS: value(ctx, DeviceOSKey),
|
||||
UserLocale: value(ctx, UserLocaleKey),
|
||||
UserRole: value(ctx, UserRoleKey),
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ func (p *OutletProcessorImpl) GetOutletByID(ctx context.Context, organizationID,
|
||||
func (p *OutletProcessorImpl) CreateOutlet(ctx context.Context, req *models.CreateOutletRequest) (*models.OutletResponse, error) {
|
||||
// Get organization ID from context
|
||||
contextInfo := appcontext.FromContext(ctx)
|
||||
if contextInfo.OrganizationID == uuid.Nil {
|
||||
if contextInfo == nil || contextInfo.OrganizationID == uuid.Nil {
|
||||
return nil, fmt.Errorf("organization ID not found in context")
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ func (p *OutletProcessorImpl) UpdateOutlet(ctx context.Context, outletID uuid.UU
|
||||
|
||||
func (p *OutletProcessorImpl) DeleteOutlet(ctx context.Context, outletID uuid.UUID) error {
|
||||
contextInfo := appcontext.FromContext(ctx)
|
||||
if contextInfo.OrganizationID == uuid.Nil {
|
||||
if contextInfo == nil || contextInfo.OrganizationID == uuid.Nil {
|
||||
return fmt.Errorf("organization ID not found in context")
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user