mirror of
https://github.com/linkwarden/linkwarden.git
synced 2026-03-03 02:37:02 +00:00
added button for administration
This commit is contained in:
@@ -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=
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
</div>
|
||||
<ul className="dropdown-content z-[1] menu shadow bg-base-200 border border-neutral-content rounded-box w-40 mt-1">
|
||||
<ul
|
||||
className={`dropdown-content z-[1] menu shadow bg-base-200 border border-neutral-content rounded-box ${
|
||||
isAdmin ? "w-48" : "w-40"
|
||||
} mt-1`}
|
||||
>
|
||||
<li>
|
||||
<Link
|
||||
href="/settings/account"
|
||||
@@ -54,6 +60,18 @@ export default function ProfileDropdown() {
|
||||
})}
|
||||
</div>
|
||||
</li>
|
||||
{isAdmin ? (
|
||||
<li>
|
||||
<Link
|
||||
href="/admin"
|
||||
onClick={() => (document?.activeElement as HTMLElement)?.blur()}
|
||||
tabIndex={0}
|
||||
role="button"
|
||||
>
|
||||
{t("server_administration")}
|
||||
</Link>
|
||||
</li>
|
||||
) : null}
|
||||
<li>
|
||||
<div
|
||||
onClick={() => {
|
||||
|
||||
@@ -36,7 +36,7 @@ export default async function isServerAdmin({ req }: Props): Promise<boolean> {
|
||||
},
|
||||
});
|
||||
|
||||
if (findUser?.username === process.env.ADMINISTRATOR) {
|
||||
if (findUser?.id === Number(process.env.NEXT_PUBLIC_ADMIN || 1)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import DeleteUserModal from "@/components/ModalContent/DeleteUserModal";
|
||||
import NewUserModal from "@/components/ModalContent/NewUserModal";
|
||||
import useUserStore from "@/store/admin/users";
|
||||
import { User as U } from "@prisma/client";
|
||||
|
||||
@@ -22,7 +22,7 @@ export default async function users(req: NextApiRequest, res: NextApiResponse) {
|
||||
},
|
||||
});
|
||||
|
||||
const isServerAdmin = process.env.ADMINISTRATOR === user?.username;
|
||||
const isServerAdmin = user?.id === Number(process.env.NEXT_PUBLIC_ADMIN || 1);
|
||||
|
||||
const userId = isServerAdmin ? Number(req.query.id) : token.id;
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ export default async function users(req: NextApiRequest, res: NextApiResponse) {
|
||||
return res.status(response.status).json({ response: response.response });
|
||||
} else if (req.method === "GET") {
|
||||
const user = await verifyUser({ req, res });
|
||||
if (!user || process.env.ADMINISTRATOR !== user.username)
|
||||
|
||||
if (!user || user.id !== Number(process.env.NEXT_PUBLIC_ADMIN || 1))
|
||||
return res.status(401).json({ response: "Unauthorized..." });
|
||||
|
||||
const response = await getUsers();
|
||||
|
||||
@@ -363,5 +363,6 @@
|
||||
"hide_link_details": "Hide Link Details",
|
||||
"link_pinned": "Link Pinned!",
|
||||
"link_unpinned": "Link Unpinned!",
|
||||
"webpage": "Webpage"
|
||||
"webpage": "Webpage",
|
||||
"server_administration": "Server Administration"
|
||||
}
|
||||
Reference in New Issue
Block a user