Skip to content

Commit 7e2298c

Browse files
fix: move allowed roles logic outside of invites loop
Signed-off-by: rohan <[email protected]>
1 parent d454d05 commit 7e2298c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

backend/backend/graphene/mutations/organisation.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ def mutate(cls, root, info, org_id, invites):
141141
f"You cannot add {len(invites)} more members to this organisation"
142142
)
143143

144+
# Restrict roles that can be assigned via invites
145+
org_roles = Role.objects.filter(organisation=org)
146+
147+
allowed_invite_roles = [
148+
r
149+
for r in org_roles
150+
if not role_has_global_access(r)
151+
and not role_has_permission(r, "create", "ServiceAccountTokens")
152+
]
153+
144154
for invite in invites:
145155
email = invite.email.lower().strip()
146156
apps = invite.apps or []
@@ -161,16 +171,6 @@ def mutate(cls, root, info, org_id, invites):
161171

162172
app_scope = App.objects.filter(id__in=apps)
163173

164-
# Restrict roles that can be assigned via invites
165-
org_roles = Role.objects.filter(organisation=org)
166-
167-
allowed_invite_roles = [
168-
r
169-
for r in org_roles
170-
if not role_has_global_access(r)
171-
and not role_has_permission(r, "create", "ServiceAccountTokens")
172-
]
173-
174174
role = Role.objects.get(organisation=org, id=role_id)
175175
if role not in allowed_invite_roles:
176176
allowed_role_names = [r.name for r in allowed_invite_roles]

0 commit comments

Comments
 (0)