@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 1 kB
JavaScript
import{copy as e}from"../../i18n/copy.mjs";import t from"../../../constants/constants.mjs";import n from"../../../utils/errors/lucid-api-error.mjs";import{multiTenancyEnabled as r}from"../../../utils/helpers/tenants.mjs";import{getMediaKeyTenantKey as i}from"../../../utils/media/media-key-tenant.mjs";import a from"../../../utils/media/normalize-media-key.mjs";import o from"../../../utils/media/get-key-visibility.mjs";import{authenticationCheck as s}from"./authenticate.mjs";import{createMiddleware as c}from"hono/factory";const l=c(async(c,l)=>{let{key:u}=c.req.param();if(!u)throw new n({type:`validation`,message:e(`server:core.errors.validation.message`)});let d=a(u);if(o(d)===t.media.visibilityKeys.private){await s(c);let t=i(d),a=c.get(`auth`);if(t&&r(c.get(`config`))&&!a.superAdmin&&!a.tenantKeys.includes(t))throw new n({type:`authorisation`,message:e(`server:core.tenants.no.access`),status:403})}return await l()});export{l as default};
//# sourceMappingURL=authorize-private-media.mjs.map