Using async SetFormatter for password field in node.js

Using async SetFormatter for password field in node.js

ruggggerrugggger Posts: 23Questions: 6Answers: 1

I would like to set my password field with a SetFormatter that will set a crypted password.

new Field('password')
.setFormatter((pass)=>{
bcript.hash(pass,12)
.then((cripted)=>{
return cripted});
}),

Since the bcript.hash method works as a promise it doesn't work.

What is the way to achieve this ?

Yaron

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi Yaron,

    The set formatters do not currently take account of Promises on return I'm afraid, so you'd need to use a synchronous version of bcrypt here.

    Allan

This discussion has been closed.