aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-07-31 16:18:03 -0500
committerFrederick Muriuki Muriithi2025-07-31 16:18:03 -0500
commita5d512f2e42352e5eb3298d1fa44d59ea25262f7 (patch)
tree714421b2d13a58f423176e0633428398bf8acb63
parent065309242ab1c7bd378faa49f25545bad4761d89 (diff)
downloadgn-auth-a5d512f2e42352e5eb3298d1fa44d59ea25262f7.tar.gz
Revoke roles a user has on group when they are removed as a member.
-rw-r--r--gn_auth/auth/authorisation/resources/groups/models.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/gn_auth/auth/authorisation/resources/groups/models.py b/gn_auth/auth/authorisation/resources/groups/models.py
index 3189302..e027b2c 100644
--- a/gn_auth/auth/authorisation/resources/groups/models.py
+++ b/gn_auth/auth/authorisation/resources/groups/models.py
@@ -359,6 +359,9 @@ def remove_user_from_group(
"DELETE FROM group_users "
"WHERE group_id=:group_id AND user_id=:user_id",
{"group_id": str(group.group_id), "user_id": str(user.user_id)})
+ cursor.execute(
+ "DELETE FROM user_roles WHERE user_id=? AND resource_id=?",
+ (str(user.user_id), str(grp_resource.resource_id)))
assign_user_role_by_name(cursor,
user,
grp_resource.resource_id,