feat: enhance contact access control; add tests for member viewing and updating foreign contacts
Test / test (push) Successful in 14s
Test / test (push) Successful in 14s
This commit is contained in:
@@ -60,7 +60,6 @@ class ContactRepository:
|
||||
user_id: int,
|
||||
) -> Contact | None:
|
||||
stmt = select(Contact).where(Contact.id == contact_id, Contact.organization_id == organization_id)
|
||||
stmt = self._apply_role_clause(stmt, role, user_id)
|
||||
result = await self._session.scalars(stmt)
|
||||
return result.first()
|
||||
|
||||
@@ -124,14 +123,4 @@ class ContactRepository:
|
||||
if role == OrganizationRole.MEMBER:
|
||||
raise ContactAccessError("Members cannot filter by owner")
|
||||
stmt = stmt.where(Contact.owner_id == params.owner_id)
|
||||
return self._apply_role_clause(stmt, role, user_id)
|
||||
|
||||
def _apply_role_clause(
|
||||
self,
|
||||
stmt: Select[tuple[Contact]],
|
||||
role: OrganizationRole,
|
||||
user_id: int,
|
||||
) -> Select[tuple[Contact]]:
|
||||
if role == OrganizationRole.MEMBER:
|
||||
return stmt.where(Contact.owner_id == user_id)
|
||||
return stmt
|
||||
|
||||
Reference in New Issue
Block a user