Jean-Sébastien Herbaux ca963a6f90 [D&P] Publish a draft (#7532)
* Add publish a draft capability.

Signed-off-by: Convly <jean-sebastien.herbaux@epitech.eu>
2020-09-22 17:39:19 +02:00

20 lines
328 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();
};