mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
2b7fbb2da6
refs https://github.com/TryGhost/Toolbox/issues/222 - Admin API has the latest version alliased without a verion to prepare to the switch in Ghost v5. As we completely control Ghost Admin it makes sense to dogfood our latest changes - Starting with Ghost v5 there will be no API versioning in the URL, this is groundwork for those new realities
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import ModalComponent from 'ghost-admin/components/modal-base';
|
|
import {fetch} from 'fetch';
|
|
import {not} from '@ember/object/computed';
|
|
import {inject as service} from '@ember/service';
|
|
import {set} from '@ember/object';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default ModalComponent.extend({
|
|
notifications: service(),
|
|
|
|
isChecked: false,
|
|
isConfirmDisabled: not('isChecked'),
|
|
|
|
actions: {
|
|
toggleCheckbox() {
|
|
set(this, 'isChecked', !this.isChecked);
|
|
},
|
|
confirm() {
|
|
this.deletePost.perform();
|
|
}
|
|
},
|
|
|
|
async _resetPasswords() {
|
|
const res = await fetch('/ghost/api/admin/authentication/reset_all_passwords/', {
|
|
method: 'POST'
|
|
});
|
|
if (res.status < 200 || res.status >= 300) {
|
|
throw new Error('api failed ' + res.status + ' ' + res.statusText);
|
|
}
|
|
},
|
|
|
|
_failure(error) {
|
|
this.notifications.showAPIError(error, {key: 'user.resetAllPasswords.failed'});
|
|
},
|
|
|
|
resetPasswords: task(function* () {
|
|
try {
|
|
yield this._resetPasswords();
|
|
window.location = window.location.href.split('#')[0];
|
|
} catch (e) {
|
|
this._failure(e);
|
|
} finally {
|
|
this.send('closeModal');
|
|
}
|
|
}).drop()
|
|
});
|