feat: default iam groups on org create

Root user is given the `Default Users` and `Root User` permission groups on org creation.
This commit is contained in:
Chris Milne 2026-06-15 11:26:22 +01:00
parent dad23733e8
commit 09d2fbafdc
2 changed files with 54 additions and 1 deletions

View file

@ -33,6 +33,7 @@ from src.contact.models import Contact
from src.contact.schemas import ContactAddress
from src.contact.exceptions import ContactNotFoundException
from src.database import db_dependency
from src.iam.service import assign_default_user_group, assign_default_root_group
from src.organisation.schemas_questionnaires import QuestionnaireQuestionsVersion0
from src.user.dependencies import (
user_model_body_dependency,
@ -183,6 +184,10 @@ async def create_org(
# Adds currently logged-in user to org users list and sets them as root_user
org_model.user_rel.append(user_model)
org_model.root_user_rel = user_model
# Creates default user and default root IAM groups and assigns them
await assign_default_user_group(db, org_model, user_model)
await assign_default_root_group(db, org_model, user_model)
for contact_type in [
"billing_contact_id",
"security_contact_id",