fix(rbac): редактор может управлять Компаниями и видит Реестр (2.4.2) - #20
Merged
Merged
Conversation
A user with the Editor role saw only «Профиль» in the menu and could not add
companies, even though the backend has allowed editors to create companies
since 2.3.0 (POST /api/v1/assets = editor+admin). The «Компании» page and its
menu link were gated admin-only, and there was no Registry link in the menu —
so editors had no navigation to their workspace.
Frontend-only fix (backend, schema, contracts unchanged):
- RoleGuard now accepts multiple roles (`role={["admin","editor"]}`).
- /admin/assets (Companies) opens to editors; AssetsPage hides the edit/archive
«Действия» column for non-admins (mirrors backend: create=editor+admin,
edit/archive=admin). Editors create + view; admins also edit/archive.
- Header menu: a «Реестр» link for all non-super_admin roles, and «Компании»
for editors + admins (moved out of the admin-only block).
- Document Types stay admin-only by design (a type sets a global notification
schedule); editors still pick from existing types when creating a document.
Verified: tsc + biome clean; no test regressions (the 8 failing registry tests
are pre-existing useSearch-mock failures, confirmed via git stash). Built and
deployed to PreProd (version.json 2.4.2, login 200).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Проблема
Пользователь с ролью Редактор видел в меню только «Профиль» и не мог добавлять Компании — хотя бэкенд с 2.3.0 разрешает редактору создавать компании (
POST /api/v1/assets= editor+admin). Страница «Компании» и её пункт меню были закрыты гардомrole="admin", а ссылки на «Реестр» в меню не было вовсе → у редактора не было навигации к своему рабочему пространству.Диагностика
GET /documents|/assets|/document-typesбез role-гейта;POST /assets= editor+admin;POST /documents= editor+admin. Причина не в бэке./registryбез role-гейта (редактор технически мог зайти через логотип/лендинг), но в меню для редактора был только «Профиль»; страница/admin/assetsзакрытаRoleGuard role="admin".Исправление (только фронтенд; бэкенд/схема/контракт не менялись)
RoleGuardтеперь принимает несколько ролей:role={["admin","editor"]}./admin/assets(Компании) открыта редактору; вAssetsPageколонка действий (редактирование/архив) скрыта для не-админов — зеркалит RBAC бэкенда (создание = editor+admin, правка/архив = admin). Редактор создаёт + просматривает; админ дополнительно правит/архивирует.Header: пункт «Реестр» для всех не-super_admin ролей и «Компании» для редакторов+админов (вынесен из admin-only блока).Матрица меню после фикса
Проверки
useSearch-mock, подтвержденоgit stash).version.json = 2.4.2, новый бандл содержит «Реестр»/«Компании», login 200 / API 401.PATCH — устранение дефекта доступа без изменения контракта.
🤖 Generated with Claude Code