mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 15:19:00 +00:00
use 'sanitizers' instead of 'utils'
This commit is contained in:
parent
43ea8fdbc6
commit
25e62db93a
@ -50,7 +50,7 @@ module.exports = ({ action, ability, model }) => {
|
|||||||
// Remove not allowed fields (RBAC)
|
// Remove not allowed fields (RBAC)
|
||||||
traverseEntity(allowedFields(permittedFields), { schema }),
|
traverseEntity(allowedFields(permittedFields), { schema }),
|
||||||
// Remove all fields of type 'password'
|
// Remove all fields of type 'password'
|
||||||
sanitize.utils.sanitizePasswords(schema)
|
sanitize.sanitizers.sanitizePasswords(schema)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,10 @@ const wrapWithEmitEvent = (event, fn) => async (entity, model) => {
|
|||||||
const result = await fn(entity, model);
|
const result = await fn(entity, model);
|
||||||
|
|
||||||
const modelDef = strapi.getModel(model);
|
const modelDef = strapi.getModel(model);
|
||||||
const sanitizedEntity = await strapiUtils.sanitize.utils.defaultSanitizeOutput(modelDef, entity);
|
const sanitizedEntity = await strapiUtils.sanitize.sanitizers.defaultSanitizeOutput(
|
||||||
|
modelDef,
|
||||||
|
entity
|
||||||
|
);
|
||||||
|
|
||||||
strapi.eventHub.emit(event, {
|
strapi.eventHub.emit(event, {
|
||||||
model: modelDef.modelName,
|
model: modelDef.modelName,
|
||||||
|
|||||||
@ -94,7 +94,7 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|||||||
|
|
||||||
async emitEvent(uid, event, entity) {
|
async emitEvent(uid, event, entity) {
|
||||||
const model = strapi.getModel(uid);
|
const model = strapi.getModel(uid);
|
||||||
const sanitizedEntity = await sanitize.utils.defaultSanitizeOutput(model, entity);
|
const sanitizedEntity = await sanitize.sanitizers.defaultSanitizeOutput(model, entity);
|
||||||
|
|
||||||
eventHub.emit(event, {
|
eventHub.emit(event, {
|
||||||
model: model.modelName,
|
model: model.modelName,
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const sendMediaMetrics = data => {
|
|||||||
module.exports = ({ strapi }) => ({
|
module.exports = ({ strapi }) => ({
|
||||||
async emitEvent(event, data) {
|
async emitEvent(event, data) {
|
||||||
const modelDef = strapi.getModel('plugin::upload.file');
|
const modelDef = strapi.getModel('plugin::upload.file');
|
||||||
const sanitizedData = await sanitize.utils.defaultSanitizeOutput(modelDef, data);
|
const sanitizedData = await sanitize.sanitizers.defaultSanitizeOutput(modelDef, data);
|
||||||
|
|
||||||
strapi.eventHub.emit(event, { media: sanitizedData });
|
strapi.eventHub.emit(event, { media: sanitizedData });
|
||||||
},
|
},
|
||||||
|
|||||||
@ -7,7 +7,7 @@ const { getNonWritableAttributes } = require('../content-types');
|
|||||||
const pipeAsync = require('../pipe-async');
|
const pipeAsync = require('../pipe-async');
|
||||||
|
|
||||||
const visitors = require('./visitors');
|
const visitors = require('./visitors');
|
||||||
const utils = require('./utils');
|
const sanitizers = require('./sanitizers');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
contentAPI: {
|
contentAPI: {
|
||||||
@ -36,7 +36,7 @@ module.exports = {
|
|||||||
return Promise.all(data.map(entry => this.output(entry, schema, { auth })));
|
return Promise.all(data.map(entry => this.output(entry, schema, { auth })));
|
||||||
}
|
}
|
||||||
|
|
||||||
const transforms = [utils.defaultSanitizeOutput(schema)];
|
const transforms = [sanitizers.defaultSanitizeOutput(schema)];
|
||||||
|
|
||||||
if (auth) {
|
if (auth) {
|
||||||
transforms.push(traverseEntity(visitors.removeRestrictedRelations(auth), { schema }));
|
transforms.push(traverseEntity(visitors.removeRestrictedRelations(auth), { schema }));
|
||||||
@ -46,6 +46,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
utils,
|
sanitizers,
|
||||||
visitors,
|
visitors,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -128,7 +128,7 @@ module.exports = ({ strapi }) => ({
|
|||||||
.then(storeEmail => storeEmail['email_confirmation'].options);
|
.then(storeEmail => storeEmail['email_confirmation'].options);
|
||||||
|
|
||||||
// Sanitize the template's user information
|
// Sanitize the template's user information
|
||||||
const sanitizedUserInfo = await sanitize.utils.defaultSanitizeOutput(userSchema, user);
|
const sanitizedUserInfo = await sanitize.sanitizers.defaultSanitizeOutput(userSchema, user);
|
||||||
|
|
||||||
const confirmationToken = crypto.randomBytes(20).toString('hex');
|
const confirmationToken = crypto.randomBytes(20).toString('hex');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user