Using async SetFormatter for password field in node.js

Using async SetFormatter for password field in node.js

ruggggerrugggger Posts: 19Questions: 5Answers: 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: 49,060Questions: 1Answers: 7,174 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

Sign In or Register to comment.