Skip to content

Commit 0327aec

Browse files
Samk13zzacharo
authored andcommitted
fix: change role.name to role.id
* related to changes in invenio-users-resources > v10.2.0
1 parent fc81d30 commit 0327aec

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

invenio_access/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This file is part of Invenio.
44
# Copyright (C) 2015-2023 CERN.
55
# Copyright (C) 2024 Graz University of Technology.
6+
# Copyright (C) 2026 KTH Royal Institute of Technology.
67
#
78
# Invenio is free software; you can redistribute it and/or modify it
89
# under the terms of the MIT License; see LICENSE file for more details.
@@ -170,7 +171,7 @@ class ActionRoles(ActionNeedMixin, db.Model):
170171
@property
171172
def need(self):
172173
"""Return RoleNeed instance."""
173-
return RoleNeed(self.role.name)
174+
return RoleNeed(self.role.id)
174175

175176

176177
class ActionSystemRoles(ActionNeedMixin, db.Model):

invenio_access/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# This file is part of Invenio.
44
# Copyright (C) 2017-2018 CERN.
5+
# Copyright (C) 2026 KTH Royal Institute of Technology.
56
#
67
# Invenio is free software; you can redistribute it and/or modify it
78
# under the terms of the MIT License; see LICENSE file for more details.
@@ -22,7 +23,7 @@ def get_identity(user):
2223
identity.provides.add(UserNeed(user.id))
2324

2425
for role in getattr(user, "roles", []):
25-
identity.provides.add(RoleNeed(role.name))
26+
identity.provides.add(RoleNeed(role.id))
2627

2728
identity.user = user
2829
return identity

tests/test_permissions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# This file is part of Invenio.
44
# Copyright (C) 2015-2023 CERN.
5+
# Copyright (C) 2026 KTH Royal Institute of Technology.
56
#
67
# Invenio is free software; you can redistribute it and/or modify it
78
# under the terms of the MIT License; see LICENSE file for more details.
@@ -96,7 +97,7 @@ def assign_roles(users_roles):
9697
for user, roles in users_roles.items():
9798
for role in roles:
9899
if not isinstance(role, Need):
99-
role = RoleNeed(role.name)
100+
role = RoleNeed(role.id)
100101
user.provides.add(role)
101102

102103

0 commit comments

Comments
 (0)