Error when opening manage acconuts #51
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
can't access property "component", (intermediate value)[type] is undefined
This happens when clicking the "Manage accounts" menu from the "Site administrator" field from the settings window from the main menu
Now let me check the i18n general strings and how the frontend maps backend error
msgkeys:The pattern is clear. Before writing the new window, let me check how
$tis made available (some windows use it in<script setup>):Let me check the passport strategy (what
req.useris, sinceisAdmindoesUser.findOne(req.user)) and register.json in es/ca:Now let me check
main.scssfor existing button/input classes so I reuse them:Now register the window and fix the settings flow:
Now the new window component:
Now the i18n strings for all three locales:
Now the test file, following the repo's source-reading test conventions:
I need to fix a broken regex in the test and verify how
$t('errors.internal')resolves given the i18n nesting:Now run the tests:
Full suite: 152 pass, 1 fail — the pre-existing, unrelated
item-folder-sync.test.jsbreakage. Let me quickly confirm what causes it, so I can report it accurately:Now a full review of the diff:
The diff is clean. Let me try a full frontend build to validate the Vue template syntax, if dependencies can be installed:
While that installs, let me re-review the final test file:
Dependencies installed quickly (cached store available). Now let me build the frontend to verify my SFC compiles:
Everything is in order — build artifacts are gitignored, and the working tree contains only the intended changes.
Summary
Root cause: The "Manage accounts" button (
SettingsWindow.vue) calledCreateWindow('account_management', …), butaccount_managementwas never registered infrontend/app/services/WindowDefinitions.jsand no component existed for it.WindowManager.vuerendersgetComponent(win.type), whosedefWindows[type].componentdereferencedundefined— exactly the reportedcan't access property "component", (intermediate value)[type] is undefined. The whole site-administration screen was missing, not just a line.What I implemented (the smallest complete fix: build the missing window and its admin-only endpoints):
frontend/app/components/windows/AccountManagementWindow.vue— new window followingCampaignSettingsWindowconventions: lists accounts (name, username, email, admin badge, "you" marker), a new-account form with the same client-side checks as the register window, and per-row make/remove administrator and delete actions (own row's switches closed).frontend/app/services/WindowDefinitions.js— registeredaccount_managementwith titlewindows.account-managementand a close handler.frontend/app/components/windows/SettingsWindow.vue—OpenManageAccountsnow usesClearWindow({ type: … })selector objects (the old bare-string calls matched neitherselector.typenorselector.idand closed nothing); back returns to the settings window, whose registry defaults already lead back to the main menu.backend/src/routes/user.js— four admin-only routes (GET /user/list,POST /user/create,POST /user/set-admin,POST /user/delete), each authenticating inline (these sit before the JWT guard) and gated by the previously-unusedisAdminmiddleware. The list never exposes passwords or setup codes; created accounts get bcrypt-hashed passwords; an admin cannot demote or delete themselves, so an instance can't be left without anybody who can manage accounts. Standard{status,msg}envelope throughout.windows.json,settings.json).tests/manage-accounts.test.js— 9 tests in the repo's source-reading style, including a general regression guard: every window type opened withCreateWindow/CreateChildWindowanywhere in the frontend must be registered, and every registered component file must exist — that catches this whole bug class before the click.Verification:
npm test→ 152/153 pass. The single failure,tests/item-folder-sync.test.js, is pre-existing and unrelated: it fails identically on the clean tree (line 529's module-levelawaitforces ESM mode while the file uses CJSrequire). I left it untouched per the "don't change unrelated files" rule. Additionally,pnpm --filter ./frontend run buildcompletes successfully, so the new SFC compiles.Implementation is ready for review: #58