Skip to content
Permalink
Browse files

bug fix: dns manager

  • Loading branch information...
usmannasir committed Sep 4, 2019
1 parent 74c1c66 commit f7cb9bd0a9ce3abafdec4f730535f8ca653db50e
Showing with 28 additions and 5 deletions.
  1. +4 −4 dns/dnsManager.py
  2. +24 −1 plogical/acl.py
@@ -157,7 +157,7 @@ def addDeleteDNSRecords(self, request = None, userID = None):
if not os.path.exists('/home/cyberpanel/powerdns'):
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0})

domainsList = ACLManager.findAllDomains(currentACL, userID)
domainsList = ACLManager.findAllWebsites(currentACL, userID)

return render(request, 'dns/addDeleteDNSRecords.html', {"domainsList": domainsList, "status": 1})

@@ -177,7 +177,7 @@ def getCurrentRecordsForDomain(self, userID = None, data = None):
currentSelection = data['currentSelection']

admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1:
if ACLManager.checkOwnership(zoneDomain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
@@ -254,7 +254,7 @@ def addDNSRecord(self, userID = None, data = None):
ttl = int(data['ttl'])

admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1:
if ACLManager.checkOwnership(zoneDomain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
@@ -424,7 +424,7 @@ def deleteDNSRecord(self, userID = None, data = None):

admin = Administrator.objects.get(pk=userID)

if ACLManager.checkOwnershipZone(delRecord.domainOwner.name, admin, currentACL) == 1:
if ACLManager.checkOwnership(delRecord.domainOwner.name, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
@@ -463,6 +463,29 @@ def findAllDomains(currentACL, userID):

return domainsList

@staticmethod
def findAllWebsites(currentACL, userID):
domainsList = []

if currentACL['admin'] == 1:
domains = Websites.objects.all()
for items in domains:
domainsList.append(items.domain)
else:
admin = Administrator.objects.get(pk=userID)
domains = admin.websites_set.all()

for items in domains:
domainsList.append(items.domain)

admins = Administrator.objects.filter(owner=admin.pk)

for items in admins:
doms = items.websites_set.all()
for dom in doms:
domainsList.append(dom.domain)
return domainsList

@staticmethod
def checkOwnership(domain, admin, currentACL):

@@ -496,7 +519,7 @@ def checkOwnershipZone(domain, admin, currentACL):

if currentACL['admin'] == 1:
return 1
elif domain.admin == admin:
elif domain.admin.admin == admin:
return 1
elif domain.admin.owner == admin.pk:
return 1

0 comments on commit f7cb9bd

Please sign in to comment.
You can’t perform that action at this time.