From 7c95761990b0d22e84e1a8b7813abe8916ff87da Mon Sep 17 00:00:00 2001 From: daniel31x13 Date: Wed, 3 Jul 2024 17:29:33 -0400 Subject: [PATCH] added button for administration --- .env.sample | 2 +- components/ProfileDropdown.tsx | 20 +++++++++++++++++++- lib/api/isServerAdmin.ts | 2 +- pages/admin.tsx | 1 - pages/api/v1/users/[id].ts | 2 +- pages/api/v1/users/index.ts | 3 ++- public/locales/en/common.json | 3 ++- 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.env.sample b/.env.sample index 4d54f0ad..65f5a816 100644 --- a/.env.sample +++ b/.env.sample @@ -21,7 +21,7 @@ BROWSER_TIMEOUT= IGNORE_UNAUTHORIZED_CA= IGNORE_HTTPS_ERRORS= IGNORE_URL_SIZE_LIMIT= -ADMINISTRATOR= +NEXT_PUBLIC_ADMIN= NEXT_PUBLIC_MAX_FILE_BUFFER= MONOLITH_MAX_BUFFER= MONOLITH_CUSTOM_OPTIONS= diff --git a/components/ProfileDropdown.tsx b/components/ProfileDropdown.tsx index c4e817b1..21ce54e7 100644 --- a/components/ProfileDropdown.tsx +++ b/components/ProfileDropdown.tsx @@ -11,6 +11,8 @@ export default function ProfileDropdown() { const { settings, updateSettings } = useLocalSettingsStore(); const { account } = useAccountStore(); + const isAdmin = account.id === Number(process.env.NEXT_PUBLIC_ADMIN || 1); + const handleToggle = () => { const newTheme = settings.theme === "dark" ? "light" : "dark"; updateSettings({ theme: newTheme }); @@ -29,7 +31,11 @@ export default function ProfileDropdown() { priority={true} /> -