mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 07:01:09 +02:00
* adds error parsing method to api service * replaces apiErrorMessage util instances with api service parseError * removes apiErrorMessage util and tests * removes ApiError type * fixes issue in isLocalStorageSupported error handling
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { service } from '@ember/service';
|
|
import Component from '@ember/component';
|
|
import { task } from 'ember-concurrency';
|
|
|
|
export default Component.extend({
|
|
router: service(),
|
|
controlGroup: service(),
|
|
api: service(),
|
|
|
|
// public attrs
|
|
model: null,
|
|
controlGroupResponse: null,
|
|
|
|
//internal state
|
|
error: null,
|
|
unwrapData: null,
|
|
|
|
unwrap: task(function* (token) {
|
|
this.set('error', null);
|
|
try {
|
|
const response = yield this.api.sys.unwrap({}, this.api.buildHeaders({ token }));
|
|
this.set('unwrapData', response.auth || response.data);
|
|
this.controlGroup.deleteControlGroupToken(this.model.id);
|
|
} catch (e) {
|
|
const { message } = yield this.api.parseError(e);
|
|
this.error = `Token unwrap failed: ${message}`;
|
|
}
|
|
}).drop(),
|
|
|
|
markAndNavigate: task(function* () {
|
|
this.controlGroup.markTokenForUnwrap(this.model.id);
|
|
const { url } = this.controlGroupResponse.uiParams;
|
|
yield this.router.transitionTo(url);
|
|
}).drop(),
|
|
});
|