acc_invoices: роль admin и переключатель роли CFO/accountant/employee; Keycloak: фирменный стиль KH Build
All checks were successful
ci / test (push) Successful in 55s
ci / deploy (push) Successful in 3m13s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 14:36:45 +03:00
parent d79ebfda10
commit b878aa72bb
9 changed files with 126 additions and 15 deletions

View File

@@ -90,7 +90,7 @@ export function buildApi(deps: ApiDeps): FastifyInstance {
return reply.code(500).send({ error: "внутренняя ошибка" });
});
const need = async (req: FastifyRequest): Promise<Actor> => authenticate(req.headers.authorization);
const need = async (req: FastifyRequest): Promise<Actor> => authenticate(req.headers.authorization, typeof req.headers["x-acting-role"] === "string" ? req.headers["x-acting-role"] : undefined);
const fail = (reply: FastifyReply, status: number, error: string) => reply.code(status).send({ error });
/** Загружает инвойс и проверяет, что он виден этому человеку (чужой выглядит как несуществующий). */
@@ -106,7 +106,7 @@ export function buildApi(deps: ApiDeps): FastifyInstance {
app.get("/api/me", async (req) => {
const a = await need(req);
return { person_id: a.personId, name: a.displayName, roles: a.roles, is_staff: isStaff(a), filters: QUICK_FILTERS };
return { person_id: a.personId, name: a.displayName, roles: a.roles, real_roles: a.realRoles, can_switch: a.canSwitch, acting_role: a.acting, is_staff: isStaff(a), filters: QUICK_FILTERS };
});
app.get("/api/lookups", async (req) => {