From 950a461fb1ae8e0ab1fd693dd942c7c1616274bb Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Thu, 1 May 2025 22:09:34 +0100 Subject: [PATCH] feat: admin user --- .env.example | 9 +++++---- src/app/globals.css | 2 +- src/app/mii/[id]/page.tsx | 2 +- src/app/profile/[id]/page.tsx | 9 ++++++++- src/app/profile/settings/page.tsx | 9 ++++++++- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index ff3cced..787db83 100644 --- a/.env.example +++ b/.env.example @@ -2,12 +2,13 @@ DATABASE_URL="postgresql://frieren:frieren@localhost:5432/tomodachi-share?schema REDIS_URL="redis://localhost:6379/0" BASE_URL=https://tomodachi-share.trafficlunar.net - NEXTAUTH_URL=https://tomodachi-share.trafficlunar.net # This should be the same as BASE_URL -AUTH_SECRET=XXXXXXXXXXXXXXXX -AUTH_TRUST_HOST=true +AUTH_TRUST_HOST=true +AUTH_SECRET=XXXXXXXXXXXXXXXX AUTH_DISCORD_ID=XXXXXXXXXXXXXXXX AUTH_DISCORD_SECRET=XXXXXXXXXXXXXXXX AUTH_GITHUB_ID=XXXXXXXXXXXXXXXX -AUTH_GITHUB_SECRET=XXXXXXXXXXXXXXXX \ No newline at end of file +AUTH_GITHUB_SECRET=XXXXXXXXXXXXXXXX + +NEXT_PUBLIC_ADMIN_USER_ID=1 \ No newline at end of file diff --git a/src/app/globals.css b/src/app/globals.css index 5c5b1e6..10b381c 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -65,7 +65,7 @@ body { } [data-tooltip]::after { - @apply content-[attr(data-tooltip)] absolute left-1/2 -translate-x-1/2 top-full mt-2 px-2 py-1 bg-orange-400 border border-orange-400 rounded text-sm text-white opacity-0 scale-75 transition-all duration-200 ease-out origin-top shadow-md whitespace-nowrap select-none pointer-events-none; + @apply content-[attr(data-tooltip)] absolute left-1/2 -translate-x-1/2 top-full mt-2 px-2 py-1 bg-orange-400 border border-orange-400 rounded-md text-sm text-white opacity-0 scale-75 transition-all duration-200 ease-out origin-top shadow-md whitespace-nowrap select-none pointer-events-none; } [data-tooltip]:hover::before, diff --git a/src/app/mii/[id]/page.tsx b/src/app/mii/[id]/page.tsx index 188ce18..7cd9704 100644 --- a/src/app/mii/[id]/page.tsx +++ b/src/app/mii/[id]/page.tsx @@ -167,7 +167,7 @@ export default async function MiiPage({ params }: Props) {
- {Number(session?.user.id) === mii.userId && ( + {session && (Number(session.user.id) === mii.userId || Number(session.user.id) === Number(process.env.NEXT_PUBLIC_ADMIN_USER_ID)) && ( <> diff --git a/src/app/profile/[id]/page.tsx b/src/app/profile/[id]/page.tsx index 1f5c554..4564530 100644 --- a/src/app/profile/[id]/page.tsx +++ b/src/app/profile/[id]/page.tsx @@ -92,7 +92,14 @@ export default async function ProfilePage({ params }: Props) { />
-

{user?.name}

+

+ {user?.name} + {user.id === Number(process.env.NEXT_PUBLIC_ADMIN_USER_ID) && ( +
+ +
+ )} +

@{user?.username}

diff --git a/src/app/profile/settings/page.tsx b/src/app/profile/settings/page.tsx index d36b6fe..e5e056f 100644 --- a/src/app/profile/settings/page.tsx +++ b/src/app/profile/settings/page.tsx @@ -39,7 +39,14 @@ export default async function ProfileSettingsPage() { />
-

{session.user.name}

+

+ {session.user.name} + {Number(session.user.id) === Number(process.env.NEXT_PUBLIC_ADMIN_USER_ID) && ( +
+ +
+ )} +

@{session.user.username}