Skip to content

Commit f7cb9bd

Browse files
committed
bug fix: dns manager
1 parent 74c1c66 commit f7cb9bd

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

dns/dnsManager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def addDeleteDNSRecords(self, request = None, userID = None):
157157
if not os.path.exists('/home/cyberpanel/powerdns'):
158158
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0})
159159

160-
domainsList = ACLManager.findAllDomains(currentACL, userID)
160+
domainsList = ACLManager.findAllWebsites(currentACL, userID)
161161

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

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

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

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

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

427-
if ACLManager.checkOwnershipZone(delRecord.domainOwner.name, admin, currentACL) == 1:
427+
if ACLManager.checkOwnership(delRecord.domainOwner.name, admin, currentACL) == 1:
428428
pass
429429
else:
430430
return ACLManager.loadError()

plogical/acl.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,29 @@ def findAllDomains(currentACL, userID):
463463

464464
return domainsList
465465

466+
@staticmethod
467+
def findAllWebsites(currentACL, userID):
468+
domainsList = []
469+
470+
if currentACL['admin'] == 1:
471+
domains = Websites.objects.all()
472+
for items in domains:
473+
domainsList.append(items.domain)
474+
else:
475+
admin = Administrator.objects.get(pk=userID)
476+
domains = admin.websites_set.all()
477+
478+
for items in domains:
479+
domainsList.append(items.domain)
480+
481+
admins = Administrator.objects.filter(owner=admin.pk)
482+
483+
for items in admins:
484+
doms = items.websites_set.all()
485+
for dom in doms:
486+
domainsList.append(dom.domain)
487+
return domainsList
488+
466489
@staticmethod
467490
def checkOwnership(domain, admin, currentACL):
468491

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

497520
if currentACL['admin'] == 1:
498521
return 1
499-
elif domain.admin == admin:
522+
elif domain.admin.admin == admin:
500523
return 1
501524
elif domain.admin.owner == admin.pk:
502525
return 1

0 commit comments

Comments
 (0)