Hashing password when creating user

Hi, I’m trying to create a user through the panel. The idea is to be able to create admin users. When creating it I need to hash the password using the same algorithm Im using in the my API. Is there a way to do that maybe using hooks?.

My project is written using NodeJS and the NestJS framework. Postgres is the database.

Thanks!

Hi @nachobenito :wave: and welcome to our community.
I suggest you to have a look on this Override writing behavior - Developer guide.
By using replaceFieldWriting you can easily achieve your goal I think.
Let me know if that help :pray:

Hi Arnaud thanks for your answer. It definitely helps!.
I can see that in documentation it says

collection.replaceFieldWriting('fullName', value => {
  const [firstName, lastName] = value.split(' ');

  return { firstName, lastName };
});

What does “collections” refers to. Do I have to import it from forest-express-sequelize.
Im pretty knew to forestadmin and not sure how to approach that. Thanks a lot!

Can you give me your project name please :pray: to see the agent version you are using.

Sure!
It is

edited

Thanks

Sorry about that, can you have a look on this exemple :pray:.
collection come from customizeCollection handler from agent.
Let me know if that help.

1 Like

It worked perfect!
Thank you very much!

2 Likes