strapi/packages/core/content-manager/config/policies/has-draft-and-publish.js
2021-04-29 13:51:12 +02:00

20 lines
329 B
JavaScript

'use strict';
const {
contentTypes: { hasDraftAndPublish },
} = require('@strapi/utils');
module.exports = (ctx, next) => {
const {
params: { model: modelUid },
} = ctx;
const model = strapi.contentTypes[modelUid];
if (!hasDraftAndPublish(model)) {
throw strapi.errors.forbidden();
}
return next();
};