Error when opening manage acconuts #51

Closed
opened 2026-10-15 11:06:14 +00:00 by Syndria98 · 17 comments
Owner

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

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
Syndria98 added the ai-ready label 2026-10-15 11:06:14 +00:00
Agent added the working label 2026-10-15 12:11:20 +00:00
Collaborator

Now let me check the i18n general strings and how the frontend maps backend error msg keys:

Now let me check the i18n general strings and how the frontend maps backend error `msg` keys:
Collaborator

The pattern is clear. Before writing the new window, let me check how $t is made available (some windows use it in <script setup>):

The pattern is clear. Before writing the new window, let me check how `$t` is made available (some windows use it in `<script setup>`):
Collaborator

Let me check the passport strategy (what req.user is, since isAdmin does User.findOne(req.user)) and register.json in es/ca:

Let me check the passport strategy (what `req.user` is, since `isAdmin` does `User.findOne(req.user)`) and register.json in es/ca:
Collaborator

Now let me check main.scss for existing button/input classes so I reuse them:

Now let me check `main.scss` for existing button/input classes so I reuse them:
Collaborator

Now register the window and fix the settings flow:

Now register the window and fix the settings flow:
Collaborator

Now the new window component:

Now the new window component:
Collaborator

Now the i18n strings for all three locales:

Now the i18n strings for all three locales:
Collaborator

Now the test file, following the repo's source-reading test conventions:

Now the test file, following the repo's source-reading test conventions:
Collaborator

I need to fix a broken regex in the test and verify how $t('errors.internal') resolves given the i18n nesting:

I need to fix a broken regex in the test and verify how `$t('errors.internal')` resolves given the i18n nesting:
Collaborator

Now run the tests:

Now run the tests:
Collaborator

Full suite: 152 pass, 1 fail — the pre-existing, unrelated item-folder-sync.test.js breakage. Let me quickly confirm what causes it, so I can report it accurately:

Full suite: 152 pass, 1 fail — the pre-existing, unrelated `item-folder-sync.test.js` breakage. Let me quickly confirm what causes it, so I can report it accurately:
Collaborator

Now a full review of the diff:

Now a full review of the diff:
Collaborator

The diff is clean. Let me try a full frontend build to validate the Vue template syntax, if dependencies can be installed:

The diff is clean. Let me try a full frontend build to validate the Vue template syntax, if dependencies can be installed:
Collaborator

While that installs, let me re-review the final test file:

While that installs, let me re-review the final test file:
Collaborator

Dependencies installed quickly (cached store available). Now let me build the frontend to verify my SFC compiles:

Dependencies installed quickly (cached store available). Now let me build the frontend to verify my SFC compiles:
Collaborator

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) called CreateWindow('account_management', …), but account_management was never registered in frontend/app/services/WindowDefinitions.js and no component existed for it. WindowManager.vue renders getComponent(win.type), whose defWindows[type].component dereferenced undefined — exactly the reported can'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 following CampaignSettingsWindow conventions: 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 — registered account_management with title windows.account-management and a close handler.
  • frontend/app/components/windows/SettingsWindow.vue — OpenManageAccounts now uses ClearWindow({ type: … }) selector objects (the old bare-string calls matched neither selector.type nor selector.id and 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-unused isAdmin middleware. 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.
  • i18n — window title and all window strings added to en / es / ca (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 with CreateWindow/CreateChildWindow anywhere 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-level await forces ESM mode while the file uses CJS require). I left it untouched per the "don't change unrelated files" rule. Additionally, pnpm --filter ./frontend run build completes successfully, so the new 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`) called `CreateWindow('account_management', …)`, but `account_management` was never registered in `frontend/app/services/WindowDefinitions.js` and no component existed for it. `WindowManager.vue` renders `getComponent(win.type)`, whose `defWindows[type].component` dereferenced `undefined` — exactly the reported `can'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 following `CampaignSettingsWindow` conventions: 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` — registered `account_management` with title `windows.account-management` and a close handler. - `frontend/app/components/windows/SettingsWindow.vue` — `OpenManageAccounts` now uses `ClearWindow({ type: … })` selector objects (the old bare-string calls matched neither `selector.type` nor `selector.id` and 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-unused `isAdmin` middleware. 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. - i18n — window title and all window strings added to **en / es / ca** (`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 with `CreateWindow`/`CreateChildWindow` anywhere 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-level `await` forces ESM mode while the file uses CJS `require`). I left it untouched per the "don't change unrelated files" rule. Additionally, `pnpm --filter ./frontend run build` completes successfully, so the new SFC compiles.
Collaborator

Implementation is ready for review: #58

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/58
Agent added help wanted and removed working labels 2026-10-15 12:36:29 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#51