|
25 | 25 | InvitationEmailSendError, |
26 | 26 | InvalidInvitationTokenError, |
27 | 27 | InvitationNotFoundError, |
| 28 | + InsufficientPermissionsError, |
| 29 | + RoleNotFoundError, |
28 | 30 | ) |
29 | 31 | from exceptions.exceptions import EmailSendFailedError |
30 | 32 | from utils.core.htmx import is_htmx_request, append_toast |
@@ -83,15 +85,12 @@ async def create_invitation( |
83 | 85 |
|
84 | 86 | # Check if the current user has permission to invite users to this organization |
85 | 87 | if not current_user.has_permission(ValidPermissions.INVITE_USER, organization): |
86 | | - raise HTTPException( |
87 | | - status_code=403, |
88 | | - detail="You don't have permission to invite users to this organization", |
89 | | - ) |
| 88 | + raise InsufficientPermissionsError() |
90 | 89 |
|
91 | 90 | # Verify the role exists and belongs to this organization |
92 | 91 | role = session.get(Role, role_id) |
93 | 92 | if not role: |
94 | | - raise HTTPException(status_code=404, detail="Role not found") |
| 93 | + raise RoleNotFoundError() |
95 | 94 | if role.organization_id != organization_id: |
96 | 95 | raise InvalidRoleForOrganizationError() |
97 | 96 |
|
@@ -205,10 +204,7 @@ async def delete_invitation( |
205 | 204 | raise OrganizationNotFoundError() |
206 | 205 |
|
207 | 206 | if not current_user.has_permission(ValidPermissions.INVITE_USER, organization): |
208 | | - raise HTTPException( |
209 | | - status_code=403, |
210 | | - detail="You don't have permission to manage invitations for this organization", |
211 | | - ) |
| 207 | + raise InsufficientPermissionsError() |
212 | 208 |
|
213 | 209 | invitation = session.get(Invitation, invitation_id) |
214 | 210 | if not invitation or invitation.organization_id != organization_id: |
|
0 commit comments