@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.53 kB
Source Map (JSON)
{"version":3,"file":"check-role-access.mjs","names":[],"sources":["../../../../src/services/roles/checks/check-role-access.ts"],"sourcesContent":["import { copy } from \"../../../libs/i18n/index.js\";\nimport { RolesRepository } from \"../../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../../utils/services/types.js\";\n\n/**\n * Loads a role through the current tenant scope before role mutations.\n * Global roles stay visible to tenant requests, matching role list reads.\n */\nconst checkRoleAccess: ServiceFn<\n\t[\n\t\t{\n\t\t\tid: number;\n\t\t},\n\t],\n\tNonNullable<Awaited<ReturnType<RolesRepository[\"selectSingleById\"]>>[\"data\"]>\n> = async (context, data) => {\n\tconst Roles = new RolesRepository(context.db.client, context.config.db);\n\n\tconst roleRes = await Roles.selectSingleById({\n\t\tid: data.id,\n\t\ttenantKey: context.request.tenantKey,\n\t\tvalidation: {\n\t\t\tenabled: true,\n\t\t\tdefaultError: {\n\t\t\t\tmessage: copy(\"server:core.roles.not.found.message\"),\n\t\t\t\tstatus: 404,\n\t\t\t},\n\t\t},\n\t});\n\tif (roleRes.error) return roleRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: roleRes.data,\n\t};\n};\n\nexport default checkRoleAccess;\n"],"mappings":"uGAQA,MAAM,EAOF,MAAO,EAAS,IAAS,CAG5B,IAAM,EAAU,MAAM,IAFJ,EAAgB,EAAQ,GAAG,OAAQ,EAAQ,OAAO,EAE1C,CAAC,CAAC,iBAAiB,CAC5C,GAAI,EAAK,GACT,UAAW,EAAQ,QAAQ,UAC3B,WAAY,CACX,QAAS,GACT,aAAc,CACb,QAAS,EAAK,qCAAqC,EACnD,OAAQ,GACT,CACD,CACD,CAAC,EAGD,OAFI,EAAQ,MAAc,EAEnB,CACN,MAAO,IAAA,GACP,KAAM,EAAQ,IACf,CACD"}