mirror of
https://github.com/strapi/strapi.git
synced 2025-07-26 02:20:32 +00:00

- Remove users-permissions sanitization step in core - Move sanitization functions to users-permissions plugin utils - Add sanitizers registry to container for manage sanitizer functions in core so that we can get/add sanitizers anywhere we want
27 lines
691 B
JavaScript
27 lines
691 B
JavaScript
'use strict';
|
|
|
|
const { curry } = require('lodash/fp');
|
|
|
|
const pipeAsync = require('../pipe-async');
|
|
const traverseEntity = require('../traverse-entity');
|
|
|
|
const { removePassword, removePrivate } = require('./visitors');
|
|
|
|
const sanitizePasswords = curry((schema, entity) => {
|
|
return traverseEntity(removePassword, { schema }, entity);
|
|
});
|
|
|
|
const sanitizePrivates = curry((schema, entity) => {
|
|
return traverseEntity(removePrivate, { schema }, entity);
|
|
});
|
|
|
|
const defaultSanitizeOutput = curry((schema, entity) => {
|
|
return pipeAsync(sanitizePrivates(schema), sanitizePasswords(schema))(entity);
|
|
});
|
|
|
|
module.exports = {
|
|
sanitizePasswords,
|
|
sanitizePrivates,
|
|
defaultSanitizeOutput,
|
|
};
|