From 0d834ee2a065e07b6ed4c2aeec94d808c9b6d3a6 Mon Sep 17 00:00:00 2001 From: Sylvain MATHIEU OBS Date: Mon, 18 Sep 2023 13:34:46 +0200 Subject: [PATCH] rbac fix: cannot add multiple time same privilege to a role --- gns3server/db/repositories/rbac.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gns3server/db/repositories/rbac.py b/gns3server/db/repositories/rbac.py index a0ed5efc..6d751465 100644 --- a/gns3server/db/repositories/rbac.py +++ b/gns3server/db/repositories/rbac.py @@ -130,6 +130,13 @@ class RbacRepository(BaseRepository): if not role_db: return None + """ + Skip add new privilege if already added for this role. + """ + for p in role_db.privileges: + if p.privilege_id == privilege.privilege_id: + return role_db + role_db.privileges.append(privilege) await self._db_session.commit() await self._db_session.refresh(role_db)