diff --git a/ghost/admin/app/controllers/staff/user.js b/ghost/admin/app/controllers/staff/user.js index 57b2f947c0..0713516d95 100644 --- a/ghost/admin/app/controllers/staff/user.js +++ b/ghost/admin/app/controllers/staff/user.js @@ -84,11 +84,13 @@ export default Controller.extend({ }, deleteUser() { - return this._deleteUser().then(() => { - this._deleteUserSuccess(); - }, () => { - this._deleteUserFailure(); - }); + return this._deleteUser() + .then(filename => this._exportDb(filename)) + .then(() => { + this._deleteUserSuccess(); + }, () => { + this._deleteUserFailure(); + }); }, toggleDeleteUserModal() { @@ -356,6 +358,21 @@ export default Controller.extend({ this.notifications.showAlert('The user could not be deleted. Please try again.', {type: 'error', key: 'user.delete.failed'}); }, + async _exportDb(filename) { + let exportUrl = this.get('ghostPaths.url').api('db'); + let downloadURL = `${exportUrl}?filename=${filename}`; + let iframe = document.getElementById('iframeDownload'); + + if (!iframe) { + iframe = document.createElement('iframe'); + iframe.id = 'iframeDownload'; + iframe.style.display = 'none'; + document.body.append(iframe); + } + + iframe.setAttribute('src', downloadURL); + }, + updateSlug: task(function* (newSlug) { let slug = this.get('user.slug');