mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +00:00
Fix sanitize bug with mongo objectid and use lower-case for getModel
This commit is contained in:
parent
5bc4a0b424
commit
444ce89b19
@ -5,6 +5,8 @@ module.exports = function sanitizeEntity(data, { model, withPrivate = false }) {
|
||||
|
||||
let plainData = typeof data.toJSON === 'function' ? data.toJSON() : data;
|
||||
|
||||
if (typeof plainData !== 'object') return plainData;
|
||||
|
||||
const attributes = model.attributes;
|
||||
return Object.keys(plainData).reduce((acc, key) => {
|
||||
const attribute = attributes[key];
|
||||
|
||||
@ -413,11 +413,12 @@ class Strapi extends EventEmitter {
|
||||
}
|
||||
|
||||
getModel(modelKey, plugin) {
|
||||
let key = modelKey.toLowerCase();
|
||||
return plugin === 'admin'
|
||||
? _.get(strapi.admin, ['models', modelKey], undefined)
|
||||
: _.get(strapi.plugins, [plugin, 'models', modelKey]) ||
|
||||
_.get(strapi, ['models', modelKey]) ||
|
||||
_.get(strapi, ['groups', modelKey]) ||
|
||||
? _.get(strapi.admin, ['models', key], undefined)
|
||||
: _.get(strapi.plugins, [plugin, 'models', key]) ||
|
||||
_.get(strapi, ['models', key]) ||
|
||||
_.get(strapi, ['groups', key]) ||
|
||||
undefined;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user