acc_invoices: роль admin и переключатель роли CFO/accountant/employee; Keycloak: фирменный стиль KH Build
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user