Skip to content

Commit

Permalink
fix: missing permission check in plugin installation tabs and theme l…
Browse files Browse the repository at this point in the history
…ist tabs extension points

Signed-off-by: Ryan Wang <i@ryanc.cc>
  • Loading branch information
ruibaby committed Sep 20, 2023
1 parent 84f413d commit e9dd0e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import LocalUpload from "./list-tabs/LocalUpload.vue";
import RemoteDownload from "./list-tabs/RemoteDownload.vue";
import { usePluginModuleStore } from "@/stores/plugin";
import type { PluginModule, ThemeListTab } from "@halo-dev/console-shared";
import { usePermission } from "@/utils/permission";
const { t } = useI18n();
const { currentUserHasPermission } = usePermission();
const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -115,7 +117,12 @@ onMounted(() => {
return;
}
const items = extensionPoints["theme:list:tabs:create"]() as ThemeListTab[];
let items = extensionPoints["theme:list:tabs:create"]() as ThemeListTab[];
items = items.filter((item) => {
return currentUserHasPermission(item.permissions);
});
tabsFromPlugins.push(...items);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import type {
} from "@halo-dev/console-shared";
import { usePluginModuleStore } from "@/stores/plugin";
import { onMounted } from "vue";
import { usePermission } from "@/utils/permission";
const { t } = useI18n();
const { currentUserHasPermission } = usePermission();
const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -92,10 +94,14 @@ onMounted(() => {
return;
}
const items = extensionPoints[
let items = extensionPoints[
"plugin:installation:tabs:create"
]() as PluginInstallationTab[];
items = items.filter((item) => {
return currentUserHasPermission(item.permissions);
});
tabs.value.push(...items);
});
Expand Down

0 comments on commit e9dd0e1

Please sign in to comment.