2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2022-01-26 17:06:18 +00:00
|
|
|
export default function setPolicy(policy) {
|
|
|
|
const { id: policyId } = server.create('policy', policy);
|
|
|
|
const clientToken = server.create('token', { type: 'client' });
|
|
|
|
clientToken.policyIds = [policyId];
|
|
|
|
clientToken.save();
|
|
|
|
|
|
|
|
window.localStorage.clear();
|
|
|
|
window.localStorage.nomadTokenSecret = clientToken.secretId;
|
|
|
|
}
|