mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Callback for role assignment (#15339)
Validate role assignment if org defined Check that organization is defined on credential before running queries. Fixes a "None type does not have attribute id" error. Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
@@ -321,6 +321,7 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
|||||||
raise ValueError('{} is not a dynamic input field'.format(field_name))
|
raise ValueError('{} is not a dynamic input field'.format(field_name))
|
||||||
|
|
||||||
def validate_role_assignment(self, actor, role_definition):
|
def validate_role_assignment(self, actor, role_definition):
|
||||||
|
if self.organization:
|
||||||
if isinstance(actor, User):
|
if isinstance(actor, User):
|
||||||
if actor.is_superuser or Organization.access_qs(actor, 'change').filter(id=self.organization.id).exists():
|
if actor.is_superuser or Organization.access_qs(actor, 'change').filter(id=self.organization.id).exists():
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user