feat(org): add organization limit per user
Add 10 organization limit per user to prevent abuse. Includes graceful fallback if count service is unavailable. - Add get_user_org_count method to OrganizationService - Check org count before allowing new organization creation - Improve invite email mismatch error message for logged-in users
This commit is contained in:
@@ -70,6 +70,22 @@ class OrganizationService:
|
||||
|
||||
return org
|
||||
|
||||
@staticmethod
|
||||
def get_user_org_count(user_id):
|
||||
"""
|
||||
Get the count of organizations a user belongs to.
|
||||
|
||||
Args:
|
||||
user_id: User ID
|
||||
|
||||
Returns:
|
||||
Count of active memberships (deleted_at is NULL)
|
||||
"""
|
||||
return OrganizationMember.query.filter_by(
|
||||
user_id=user_id,
|
||||
deleted_at=None,
|
||||
).count()
|
||||
|
||||
@staticmethod
|
||||
def get_organization_by_id(org_id):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user