I'm trying out the new strapi v4 right now (4.0.0) community edition. I've got a custom controller which queries for the current user and (in the future) fetches related objects.
When I did this with strapi v3 I used the built-in sanititzeEntitiy
- helper function to remove sensitive fields from the user instance. In v4 however, this function appears to not exist anymore and I can't figure out how to achieve this.
Is there anyone that can help me with this? My code so far is:
module.exports = {
currentUser: async(ctx, next) => {
let user = ctx.state.user;
// TODO: sanitize this
}
}
In v3 I just did return sanitizeEntity(user);
which would have the desired effect. I just can't figure out how to do this in v4 and I can't find anything related to that in the docs.
./config/api.js
and in the exported object add the following:responses: { privateAttributes: ['password', 'another_sensitive_field'] }
, would that help? – Intertype