From 5ed9d0e1f8c715951dfe7be66e5af654f89b20e6 Mon Sep 17 00:00:00 2001 From: Micha Date: Wed, 24 Dec 2025 13:29:28 +0100 Subject: [PATCH] Add ACP shell and JWT claims --- .../EventSubscriber/JwtCreatedSubscriber.php | 24 ++++++++++ api/translations/messages.de.po | 27 +++++++++++ api/translations/messages.en.po | 27 +++++++++++ frontend/src/App.jsx | 10 +++- frontend/src/context/AuthContext.jsx | 48 ++++++++++++++++++- frontend/src/pages/Acp.jsx | 32 +++++++++++++ 6 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 api/src/EventSubscriber/JwtCreatedSubscriber.php create mode 100644 frontend/src/pages/Acp.jsx diff --git a/api/src/EventSubscriber/JwtCreatedSubscriber.php b/api/src/EventSubscriber/JwtCreatedSubscriber.php new file mode 100644 index 0000000..e3f4994 --- /dev/null +++ b/api/src/EventSubscriber/JwtCreatedSubscriber.php @@ -0,0 +1,24 @@ +getUser(); + if (!$user instanceof User) { + return; + } + + $payload = $event->getData(); + $payload['user_id'] = $user->getId(); + $payload['username'] = $user->getUsername(); + $event->setData($payload); + } +} diff --git a/api/translations/messages.de.po b/api/translations/messages.de.po index d0fc0b3..e13a186 100644 --- a/api/translations/messages.de.po +++ b/api/translations/messages.de.po @@ -164,3 +164,30 @@ msgstr "Registrierung läuft..." msgid "form.create_account" msgstr "Konto erstellen" + +msgid "nav.acp" +msgstr "ACP" + +msgid "acp.title" +msgstr "Administrationsbereich" + +msgid "acp.no_access" +msgstr "Du hast keinen Zugriff auf diesen Bereich." + +msgid "acp.general" +msgstr "Allgemein" + +msgid "acp.general_hint" +msgstr "Globale Einstellungen und Board-Konfiguration erscheinen hier." + +msgid "acp.forums" +msgstr "Foren" + +msgid "acp.forums_hint" +msgstr "Kategorien und Foren in einer Baumansicht verwalten." + +msgid "acp.users" +msgstr "Benutzer" + +msgid "acp.users_hint" +msgstr "Werkzeuge zur Benutzerverwaltung erscheinen hier." diff --git a/api/translations/messages.en.po b/api/translations/messages.en.po index 1f29c0a..6f10fdf 100644 --- a/api/translations/messages.en.po +++ b/api/translations/messages.en.po @@ -164,3 +164,30 @@ msgstr "Registering..." msgid "form.create_account" msgstr "Create account" + +msgid "nav.acp" +msgstr "ACP" + +msgid "acp.title" +msgstr "Admin control panel" + +msgid "acp.no_access" +msgstr "You do not have access to this area." + +msgid "acp.general" +msgstr "General" + +msgid "acp.general_hint" +msgstr "Global settings and board configuration will appear here." + +msgid "acp.forums" +msgstr "Forums" + +msgid "acp.forums_hint" +msgstr "Manage categories and forums from a tree view." + +msgid "acp.users" +msgstr "Users" + +msgid "acp.users_hint" +msgstr "User management tools will appear here." diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index d283cdd..3544ea0 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -6,10 +6,11 @@ import ForumView from './pages/ForumView' import ThreadView from './pages/ThreadView' import Login from './pages/Login' import Register from './pages/Register' +import Acp from './pages/Acp' import { useTranslation } from 'react-i18next' function Navigation() { - const { token, email, logout } = useAuth() + const { token, email, logout, isAdmin } = useAuth() const { t, i18n } = useTranslation() const handleLanguageChange = (locale) => { @@ -29,6 +30,11 @@ function Navigation() { {t('nav.forums')} + {isAdmin && ( + + {t('nav.acp')} + + )} {!token && ( <> @@ -62,6 +68,7 @@ function Navigation() { function AppShell() { const { t } = useTranslation() + const { isAdmin } = useAuth() return (
@@ -72,6 +79,7 @@ function AppShell() { } /> } /> } /> + } />