fix: Disassociate domains from account before deletion

This commit is contained in:
Jérôme BECOT 2022-02-21 17:32:44 +01:00
parent 6ba1254759
commit 84a183d913
No known key found for this signature in database
GPG Key ID: 6667C39A7C2DBD6F

View File

@ -940,6 +940,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()