mirror of
https://github.com/strapi/strapi.git
synced 2025-07-20 23:47:46 +00:00
30 lines
700 B
JavaScript
30 lines
700 B
JavaScript
'use strict';
|
|
|
|
const { getService } = require('../utils');
|
|
const { ACTIONS, FILE_MODEL_UID } = require('../constants');
|
|
const validateConfig = require('./validation/admin/configureView');
|
|
|
|
module.exports = {
|
|
async updateViewConfiguration(ctx) {
|
|
const {
|
|
request: { body },
|
|
state: { userAbility },
|
|
} = ctx;
|
|
|
|
if (userAbility.cannot(ACTIONS.configureView, FILE_MODEL_UID)) {
|
|
return ctx.forbidden();
|
|
}
|
|
|
|
const data = await validateConfig(body);
|
|
await getService('upload').setConfiguration(data);
|
|
|
|
ctx.body = { data };
|
|
},
|
|
|
|
async getViewConfiguration(ctx) {
|
|
const data = await getService('upload').getConfiguration();
|
|
|
|
ctx.body = { data };
|
|
},
|
|
};
|