mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
24 lines
688 B
JavaScript
24 lines
688 B
JavaScript
|
import Component from '@glimmer/component';
|
||
|
import {action} from '@ember/object';
|
||
|
import {inject as service} from '@ember/service';
|
||
|
|
||
|
export default class RegenerateStaffTokenModal extends Component {
|
||
|
@service ajax;
|
||
|
@service ghostPaths;
|
||
|
@service notifications;
|
||
|
|
||
|
@action
|
||
|
async regenerateStaffToken() {
|
||
|
const url = this.ghostPaths.url.api('users', 'me', 'token');
|
||
|
|
||
|
try {
|
||
|
const {apiKey} = await this.ajax.put(url, {data: {}});
|
||
|
|
||
|
this.args.close(`${apiKey.id}:${apiKey.secret}`);
|
||
|
} catch (error) {
|
||
|
this.notifications.showAPIError(error, {key: 'token.regenerate'});
|
||
|
this.args.close();
|
||
|
}
|
||
|
}
|
||
|
}
|