Make capabilities checking use the right paths.
This commit is contained in:
parent
6667b42c9f
commit
4c784d9a32
|
@ -2,7 +2,7 @@ import { Component, JSX, render } from "preact";
|
|||
import { DoesNotExistError } from "../../../types/internalErrors";
|
||||
import { Page } from "../../../types/Page";
|
||||
import { SecretTitleElement } from "../SecretTitleElement";
|
||||
import { getCapsPath } from "../../../api/sys/getCapabilities";
|
||||
import { getCapabilitiesPath, getCapsPath } from "../../../api/sys/getCapabilities";
|
||||
import { getSecrets } from "../../../api/kv/getSecrets";
|
||||
import { setErrorText } from "../../../pageUtils";
|
||||
import i18next from "i18next";
|
||||
|
@ -124,12 +124,19 @@ export class KeyValueViewPage extends Page {
|
|||
}
|
||||
}
|
||||
async render(): Promise<void> {
|
||||
const caps = await getCapsPath("/sys/mounts/" + this.state.baseMount);
|
||||
const mountsPath = "/sys/mounts/" + this.state.baseMount;
|
||||
const currentPath = this.state.baseMount + this.state.secretPath.join("/");
|
||||
const caps = await getCapabilitiesPath([
|
||||
mountsPath,
|
||||
currentPath
|
||||
]);
|
||||
const mountCaps = caps[mountsPath];
|
||||
const pathCaps = caps[currentPath];
|
||||
|
||||
render(
|
||||
<>
|
||||
<p>
|
||||
{caps.includes("create") && (
|
||||
{pathCaps.includes("create") && (
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
|
@ -139,7 +146,7 @@ export class KeyValueViewPage extends Page {
|
|||
{i18next.t("kv_view_new_btn")}
|
||||
</button>
|
||||
)}
|
||||
{this.state.secretPath.length == 0 && caps.includes("delete") && (
|
||||
{this.state.secretPath.length == 0 && mountCaps.includes("delete") && (
|
||||
<button
|
||||
class="uk-button uk-button-danger"
|
||||
onClick={async () => {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Grid, GridSizes } from "../../../elements/Grid";
|
|||
import { MarginInline } from "../../../elements/MarginInline";
|
||||
import { Page } from "../../../types/Page";
|
||||
import { SecretTitleElement } from "../SecretTitleElement";
|
||||
import { getCapsPath } from "../../../api/sys/getCapabilities";
|
||||
import { getCapabilitiesPath, getCapsPath } from "../../../api/sys/getCapabilities";
|
||||
import { getTOTPCode } from "../../../api/totp/getTOTPCode";
|
||||
import { getTOTPKeys } from "../../../api/totp/getTOTPKeys";
|
||||
import { removeDoubleSlash } from "../../../utils";
|
||||
|
@ -80,12 +80,18 @@ export class TOTPViewPage extends Page {
|
|||
async render(): Promise<void> {
|
||||
this.state.secretItem = "";
|
||||
|
||||
const caps = await getCapsPath("/sys/mounts/" + this.state.baseMount);
|
||||
const mountsPath = "/sys/mounts/" + this.state.baseMount;
|
||||
const caps = await getCapabilitiesPath([
|
||||
mountsPath,
|
||||
this.state.baseMount,
|
||||
]);
|
||||
const mountCaps = caps[mountsPath];
|
||||
const totpCaps = caps[this.state.baseMount];
|
||||
|
||||
render(
|
||||
<div>
|
||||
<p>
|
||||
{caps.includes("create") && (
|
||||
{totpCaps.includes("create") && (
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
|
@ -95,7 +101,7 @@ export class TOTPViewPage extends Page {
|
|||
{i18next.t("totp_view_new_btn")}
|
||||
</button>
|
||||
)}
|
||||
{caps.includes("delete") && (
|
||||
{mountCaps.includes("delete") && (
|
||||
<button
|
||||
class="uk-button uk-button-danger"
|
||||
onClick={async () => {
|
||||
|
@ -106,8 +112,6 @@ export class TOTPViewPage extends Page {
|
|||
</button>
|
||||
)}
|
||||
</p>
|
||||
<br />
|
||||
<br />
|
||||
<div id="totpList">
|
||||
{
|
||||
await (async () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Component, JSX, render } from "preact";
|
||||
import { Page } from "../../../types/Page";
|
||||
import { SecretTitleElement } from "../SecretTitleElement";
|
||||
import { getCapsPath } from "../../../api/sys/getCapabilities";
|
||||
import { getCapabilitiesPath, getCapsPath } from "../../../api/sys/getCapabilities";
|
||||
import { getTransitKeys } from "../../../api/transit/getTransitKeys";
|
||||
import i18next from "i18next";
|
||||
|
||||
|
@ -81,12 +81,18 @@ export class TransitViewPage extends Page {
|
|||
async render(): Promise<void> {
|
||||
this.state.secretItem = "";
|
||||
|
||||
const caps = await getCapsPath("/sys/mounts/" + this.state.baseMount);
|
||||
const mountsPath = "/sys/mounts/" + this.state.baseMount;
|
||||
const caps = await getCapabilitiesPath([
|
||||
mountsPath,
|
||||
this.state.baseMount,
|
||||
]);
|
||||
const mountCaps = caps[mountsPath];
|
||||
const transitCaps = caps[this.state.baseMount];
|
||||
|
||||
render(
|
||||
<>
|
||||
<p>
|
||||
{caps.includes("create") && (
|
||||
{transitCaps.includes("create") && (
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
|
@ -96,7 +102,7 @@ export class TransitViewPage extends Page {
|
|||
{i18next.t("transit_view_new_btn")}
|
||||
</button>
|
||||
)}
|
||||
{caps.includes("delete") && (
|
||||
{mountCaps.includes("delete") && (
|
||||
<button
|
||||
class="uk-button uk-button-danger"
|
||||
onClick={async () => {
|
||||
|
|
Loading…
Reference in a new issue