mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
Rewrote delete into generator function
- Wasn't necessary, but thought this might fix the problem when there's no 'meta' in the reponse object
This commit is contained in:
parent
70524c55a4
commit
f42f2a29a3
@ -83,16 +83,6 @@ export default Controller.extend({
|
||||
this.set('dirtyAttributes', true);
|
||||
},
|
||||
|
||||
deleteUser() {
|
||||
return this._deleteUser()
|
||||
.then(filename => this._exportDb(filename))
|
||||
.then(() => {
|
||||
this._deleteUserSuccess();
|
||||
}, () => {
|
||||
this._deleteUserFailure();
|
||||
});
|
||||
},
|
||||
|
||||
toggleDeleteUserModal() {
|
||||
if (this.deleteUserActionIsVisible) {
|
||||
this.toggleProperty('showDeleteUserModal');
|
||||
@ -341,13 +331,6 @@ export default Controller.extend({
|
||||
}
|
||||
},
|
||||
|
||||
_deleteUser() {
|
||||
if (this.deleteUserActionIsVisible) {
|
||||
let user = this.user;
|
||||
return user.destroyRecord();
|
||||
}
|
||||
},
|
||||
|
||||
_deleteUserSuccess() {
|
||||
this.notifications.closeAlerts('user.delete');
|
||||
this.store.unloadAll('post');
|
||||
@ -358,7 +341,7 @@ 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) {
|
||||
_exportDb(filename) {
|
||||
let exportUrl = this.get('ghostPaths.url').api('db');
|
||||
let downloadURL = `${exportUrl}?filename=${filename}`;
|
||||
let iframe = document.getElementById('iframeDownload');
|
||||
@ -373,6 +356,20 @@ export default Controller.extend({
|
||||
iframe.setAttribute('src', downloadURL);
|
||||
},
|
||||
|
||||
deleteUser: task(function *() {
|
||||
try {
|
||||
const result = yield this.user.destroyRecord();
|
||||
|
||||
if (result.get('meta') && result.get('meta.filename')) {
|
||||
yield this._exportDb(result.meta.filename);
|
||||
}
|
||||
|
||||
this._deleteUserSuccess();
|
||||
} catch {
|
||||
this._deleteUserFailure();
|
||||
}
|
||||
}),
|
||||
|
||||
updateSlug: task(function* (newSlug) {
|
||||
let slug = this.get('user.slug');
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
||||
{{#if this.showDeleteUserModal}}
|
||||
<GhFullscreenModal @modal="delete-user"
|
||||
@model={{this.user}}
|
||||
@confirm={{action "deleteUser"}}
|
||||
@confirm={{action (perform this.deleteUser)}}
|
||||
@close={{action "toggleDeleteUserModal"}}
|
||||
@modifier="action wide" />
|
||||
{{/if}}
|
||||
|
Loading…
Reference in New Issue
Block a user