feat(multi-tenancy): implement critical fixes for orphaned users and permissions
- Simplified HasTenantAccess permission logic to ensure every authenticated user has an account. - Added fallback to system account for OpenAI settings in AI configuration. - Allowed any authenticated user to check task progress in IntegrationSettingsViewSet. - Created a script to identify and fix orphaned users without accounts. - Updated error response handling in business endpoints for clarity.
This commit is contained in:
@@ -80,6 +80,10 @@ class SiteSerializer(serializers.ModelSerializer):
|
||||
'created_at', 'updated_at'
|
||||
]
|
||||
read_only_fields = ['created_at', 'updated_at', 'account']
|
||||
# Explicitly specify required fields for clarity
|
||||
extra_kwargs = {
|
||||
'industry': {'required': True, 'error_messages': {'required': 'Industry is required when creating a site.'}},
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Allow partial updates for PATCH requests."""
|
||||
@@ -87,10 +91,12 @@ class SiteSerializer(serializers.ModelSerializer):
|
||||
# Make slug optional - it will be auto-generated from name if not provided
|
||||
if 'slug' in self.fields:
|
||||
self.fields['slug'].required = False
|
||||
# For partial updates (PATCH), make name optional
|
||||
# For partial updates (PATCH), make name and industry optional
|
||||
if self.partial:
|
||||
if 'name' in self.fields:
|
||||
self.fields['name'].required = False
|
||||
if 'industry' in self.fields:
|
||||
self.fields['industry'].required = False
|
||||
|
||||
def validate_domain(self, value):
|
||||
"""Ensure domain has https:// protocol.
|
||||
|
||||
Reference in New Issue
Block a user