mirror of
https://github.com/ansible/awx.git
synced 2026-07-30 09:29:54 -02:30
Allow orphaned user to be added to org
Fixed bug where an org admin was not able to add an orphaned user to the org, in the case where the orphan had an ancestor role that matched one of the roles for of the org admin. scenario to fix -- sue is member of cred1, where cred1 is part of org1. org1 admin cannot add sue to org1, because the cred1 role for sue has an ancestor to org1 role. The org1 admin cannot change or attach sue to org1. tower issue #4198 and #4197
This commit is contained in:
@@ -11,7 +11,6 @@ from functools import reduce
|
||||
from django.conf import settings
|
||||
from django.db.models import Q, Prefetch
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
@@ -650,8 +649,8 @@ class UserAccess(BaseAccess):
|
||||
# in these cases only superusers can modify orphan users
|
||||
return False
|
||||
return not obj.roles.all().exclude(
|
||||
content_type=ContentType.objects.get_for_model(User)
|
||||
).filter(ancestors__in=self.user.roles.all()).exists()
|
||||
ancestors__in=self.user.roles.all()
|
||||
).exists()
|
||||
else:
|
||||
return self.is_all_org_admin(obj)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user