mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			329 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			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();
 | |
| };
 | 
