mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-25 01:38:08 +00:00
rbac fix: cannot add multiple time same privilege to a role
This commit is contained in:
parent
e1c5c05492
commit
0d834ee2a0
@ -130,6 +130,13 @@ class RbacRepository(BaseRepository):
|
|||||||
if not role_db:
|
if not role_db:
|
||||||
return None
|
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)
|
role_db.privileges.append(privilege)
|
||||||
await self._db_session.commit()
|
await self._db_session.commit()
|
||||||
await self._db_session.refresh(role_db)
|
await self._db_session.refresh(role_db)
|
||||||
|
Loading…
Reference in New Issue
Block a user