Created_by & updated_by

Hello Guys,
I have a simple question: when I use “findOne” I get an object with user information “created_by” and “updated_by”. Unfortunately, I find the full user objects therein, e.g. B. “User email” and “hash password” etc. :roll_eyes:
Can I set somewhere that Strapi withholds this information?

Thanks in advance! :thinking:

I think you can modify the collection controller and remove those fields.

https://strapi.io/documentation/developer-docs/latest/concepts/controllers.html#core-controllers

findOne function is like that:

const { sanitizeEntity } = require('strapi-utils');

module.exports = {
  /**
   * Retrieve a record.
   *
   * @return {Object}
   */

  async findOne(ctx) {
    const { id } = ctx.params;

    const entity = await strapi.services.restaurant.findOne({ id });
    return sanitizeEntity(entity, { model: strapi.models.restaurant });
  },
};

Maybe you can get the entity and modify created_by. There may be another, simpler way to do this. But I’m new to Strapi and some things I needed to change the controllers.

1 Like

@gabrielgouv :+1: Many Thanks! I started incorporating this method into my project. :slightly_smiling_face:

1 Like