1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Merge pull request #2285 from Orange-OpenSource/3.0

rbac fix: cannot add multiple time same privilege to a role
This commit is contained in:
Jeremy Grossmann 2023-09-18 18:41:01 +07:00 committed by GitHub
commit eca1243fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)