File size: 1,164 Bytes
042f4ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright (c) 2026 CrewHub. All rights reserved.
# Proprietary and confidential. See LICENSE for details.
"""Permission checking utilities."""

from uuid import UUID

from src.core.exceptions import ForbiddenError


def check_agent_owner(agent_owner_id: UUID, current_user_id: UUID) -> None:
    """Verify that the current user is the owner of the agent.

    Args:
        agent_owner_id: The UUID of the agent's owner.
        current_user_id: The UUID of the currently authenticated user.

    Raises:
        ForbiddenError: If the user is not the agent owner.
    """
    if agent_owner_id != current_user_id:
        raise ForbiddenError(detail="You do not own this agent")


def check_account_owner(account_owner_id: UUID, current_user_id: UUID) -> None:
    """Verify that the current user is the owner of the account.

    Args:
        account_owner_id: The UUID of the account's owner.
        current_user_id: The UUID of the currently authenticated user.

    Raises:
        ForbiddenError: If the user is not the account owner.
    """
    if account_owner_id != current_user_id:
        raise ForbiddenError(detail="You do not own this account")