refactor(scripts): remove admin role checks from plugin API endpoints

- Eliminated admin role checks from the create, install, and delete plugin API endpoints to simplify access control.
- Updated the ScriptsPage component to remove unnecessary user role checks, streamlining the installation process for all users.
- Improved UI by consolidating the zip installation button, enhancing user experience during plugin management.
This commit is contained in:
2026-08-30 20:39:25 +07:00
parent 88d3692116
commit 80e9c91b88
2 changed files with 15 additions and 23 deletions
-3
View File
@@ -466,7 +466,6 @@ export default function scriptsPluginFactory(registry) {
fastify.post(
"/plugins/create",
{ onRequest: [fastify.requireAdmin] },
async (req, reply) => {
const body = /** @type {{ id?: string, content?: string, description?: string }} */ (
req.body ?? {}
@@ -498,7 +497,6 @@ export default function scriptsPluginFactory(registry) {
fastify.post(
"/plugins/install",
{ onRequest: [fastify.requireAdmin] },
async (req, reply) => {
const body = /** @type {{
source?: string,
@@ -573,7 +571,6 @@ export default function scriptsPluginFactory(registry) {
fastify.delete(
"/plugins/:id",
{ onRequest: [fastify.requireAdmin] },
async (req, reply) => {
const { id } = /** @type {{ id: string }} */ (req.params);
try {
-5
View File
@@ -7,7 +7,6 @@ import {
useDuplicatePlugin,
useForkScript,
useInstallPlugin,
useMe,
useScripts,
} from "../api/hooks.js";
import { ConfirmDialog } from "../components/ConfirmDialog.jsx";
@@ -46,8 +45,6 @@ export function ScriptsPage() {
const fork = useForkScript();
const duplicate = useDuplicatePlugin();
const install = useInstallPlugin();
const me = useMe();
const isAdmin = me.data?.user?.role === "admin";
const { notify } = useNotifications();
const [pendingZip, setPendingZip] = useState(null);
const [zipEncoding, setZipEncoding] = useState(false);
@@ -144,7 +141,6 @@ export function ScriptsPage() {
>
Install example
</button>
{isAdmin ? (
<label className={`btn btn-outline btn-sm ${zipBusy ? "btn-disabled" : ""}`}>
{zipBusy ? (
<span className="loading loading-spinner loading-xs" />
@@ -160,7 +156,6 @@ export function ScriptsPage() {
onChange={onPickZip}
/>
</label>
) : null}
<Link to="/scripts/new" className="btn btn-primary btn-sm">
<LuPlus className="size-4" />
Add plugin