Skip to content

Commit 4e653a7

Browse files
authored
Extend membership acces to cdr admins (#803)
### Description Please explain the changes you made here. ### Checklist - [ ] Created tests which fail without the change (if possible) - [ ] All tests passing - [ ] Extended the documentation, if necessary
1 parent 0cadef2 commit 4e653a7

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

app/core/memberships/endpoints_memberships.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,14 @@ async def read_association_membership(
7979
if db_association_membership is None:
8080
raise HTTPException(status_code=404, detail="Association Membership not found")
8181

82-
if db_association_membership.manager_group_id not in [
83-
group.id for group in user.groups
84-
] and GroupType.admin not in [group.id for group in user.groups]:
82+
if not is_user_member_of_any_group(
83+
user,
84+
[
85+
db_association_membership.manager_group_id,
86+
GroupType.admin,
87+
GroupType.admin_cdr,
88+
],
89+
):
8590
raise HTTPException(
8691
status_code=403,
8792
detail="User is not allowed to access this membership",
@@ -232,9 +237,10 @@ async def read_user_memberships(
232237
# Check if the user is trying to access their own memberships or if they are an admin
233238
# If the user is not an admin or the user_id does not match the current user,
234239
# filter the query to get the managed memberships from user's groups.
235-
if user_id != user.id and GroupType.admin not in [
236-
group.id for group in user.groups
237-
]:
240+
if user_id != user.id and not is_user_member_of_any_group(
241+
user,
242+
[GroupType.admin, GroupType.admin_cdr],
243+
):
238244
return await cruds_memberships.get_user_memberships_by_user_id(
239245
db,
240246
user_id,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [{ name = "AEECL ECLAIR" }]
66

77
# Hyperion follows Semantic Versioning
88
# https://semver.org/
9-
version = "4.7.1"
9+
version = "4.7.2"
1010
minimal-titan-version-code = 139
1111
requires-python = ">= 3.11, < 3.13"
1212

0 commit comments

Comments
 (0)