mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
Merge pull request #1134 from jbe-dw/fixAPIDeleteAccount
Fix API Account deletion
This commit is contained in:
commit
fa9bdcfde0
@ -806,7 +806,7 @@ class Domain(db.Model):
|
|||||||
else:
|
else:
|
||||||
return {'status': 'error', 'msg': 'This domain does not exist'}
|
return {'status': 'error', 'msg': 'This domain does not exist'}
|
||||||
|
|
||||||
def assoc_account(self, account_id):
|
def assoc_account(self, account_id, update=True):
|
||||||
"""
|
"""
|
||||||
Associate domain with a domain, specified by account id
|
Associate domain with a domain, specified by account id
|
||||||
"""
|
"""
|
||||||
@ -842,7 +842,8 @@ class Domain(db.Model):
|
|||||||
current_app.logger.error(jdata['error'])
|
current_app.logger.error(jdata['error'])
|
||||||
return {'status': 'error', 'msg': jdata['error']}
|
return {'status': 'error', 'msg': jdata['error']}
|
||||||
else:
|
else:
|
||||||
self.update()
|
if update:
|
||||||
|
self.update()
|
||||||
msg_str = 'Account changed for domain {0} successfully'
|
msg_str = 'Account changed for domain {0} successfully'
|
||||||
current_app.logger.info(msg_str.format(domain_name))
|
current_app.logger.info(msg_str.format(domain_name))
|
||||||
return {'status': 'ok', 'msg': 'account changed successfully'}
|
return {'status': 'ok', 'msg': 'account changed successfully'}
|
||||||
|
@ -941,6 +941,18 @@ def api_delete_account(account_id):
|
|||||||
account = account_list[0]
|
account = account_list[0]
|
||||||
else:
|
else:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
current_app.logger.debug(
|
||||||
|
f'Deleting Account {account.name}'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Remove account association from domains first
|
||||||
|
if len(account.domains) > 0:
|
||||||
|
for domain in account.domains:
|
||||||
|
current_app.logger.info(f"Disassociating domain {domain.name} with {account.name}")
|
||||||
|
Domain(name=domain.name).assoc_account(None, update=False)
|
||||||
|
current_app.logger.info("Syncing all domains")
|
||||||
|
Domain().update()
|
||||||
|
|
||||||
current_app.logger.debug(
|
current_app.logger.debug(
|
||||||
"Deleting account {} ({})".format(account_id, account.name))
|
"Deleting account {} ({})".format(account_id, account.name))
|
||||||
result = account.delete_account()
|
result = account.delete_account()
|
||||||
|
Loading…
Reference in New Issue
Block a user