Merge pull request #1134 from jbe-dw/fixAPIDeleteAccount

Fix API Account deletion
This commit is contained in:
jbe-dw
2022-05-06 23:35:24 +02:00
committed by GitHub
2 changed files with 15 additions and 2 deletions

View File

@ -941,6 +941,18 @@ def api_delete_account(account_id):
account = account_list[0]
else:
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(
"Deleting account {} ({})".format(account_id, account.name))
result = account.delete_account()