mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 18:08:11 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			39 lines
		
	
	
		
			832 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			832 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const { getService } = require('../utils');
 | |
| const { ACTIONS, FILE_MODEL_UID } = require('../constants');
 | |
| const validateSettings = require('./validation/admin/settings');
 | |
| 
 | |
| module.exports = {
 | |
|   async updateSettings(ctx) {
 | |
|     const {
 | |
|       request: { body },
 | |
|       state: { userAbility },
 | |
|     } = ctx;
 | |
| 
 | |
|     if (userAbility.cannot(ACTIONS.readSettings, FILE_MODEL_UID)) {
 | |
|       return ctx.forbidden();
 | |
|     }
 | |
| 
 | |
|     const data = await validateSettings(body);
 | |
| 
 | |
|     await getService('upload').setSettings(data);
 | |
| 
 | |
|     ctx.body = { data };
 | |
|   },
 | |
| 
 | |
|   async getSettings(ctx) {
 | |
|     const {
 | |
|       state: { userAbility },
 | |
|     } = ctx;
 | |
| 
 | |
|     if (userAbility.cannot(ACTIONS.readSettings, FILE_MODEL_UID)) {
 | |
|       return ctx.forbidden();
 | |
|     }
 | |
| 
 | |
|     const data = await getService('upload').getSettings();
 | |
| 
 | |
|     ctx.body = { data };
 | |
|   },
 | |
| };
 | 
