Skip to content

Commit eca1243

Browse files
authored
Merge pull request #2285 from Orange-OpenSource/3.0
rbac fix: cannot add multiple time same privilege to a role
2 parents e1c5c05 + 0d834ee commit eca1243

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

gns3server/db/repositories/rbac.py

+7
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ async def add_privilege_to_role(
130130
if not role_db:
131131
return None
132132

133+
"""
134+
Skip add new privilege if already added for this role.
135+
"""
136+
for p in role_db.privileges:
137+
if p.privilege_id == privilege.privilege_id:
138+
return role_db
139+
133140
role_db.privileges.append(privilege)
134141
await self._db_session.commit()
135142
await self._db_session.refresh(role_db)

0 commit comments

Comments
 (0)