Code optimization of create application credential
We check if user has specified roles in project when creating application credential. The code can be optimized here instead of two level loop. Change-Id: I9de223b693d33a45331af9ffd2960f733c6b43da
This commit is contained in:
parent
ea774f78e0
commit
954bd1a9cc
@ -82,9 +82,7 @@ class Manager(manager.Manager):
|
||||
def _require_user_has_role_in_project(self, roles, user_id, project_id):
|
||||
user_roles = self._get_user_roles(user_id, project_id)
|
||||
for role in roles:
|
||||
matching_roles = [x for x in user_roles
|
||||
if x == role['id']]
|
||||
if not matching_roles:
|
||||
if role['id'] not in user_roles:
|
||||
raise exception.RoleAssignmentNotFound(role_id=role['id'],
|
||||
actor_id=user_id,
|
||||
target_id=project_id)
|
||||
|
Loading…
Reference in New Issue
Block a user