node.bcrypt.js icon indicating copy to clipboard operation
node.bcrypt.js copied to clipboard

[bug] bcrypt.compare always returns "true"

Open D50000 opened this issue 9 months ago • 2 comments

I am working on next.js project then encounter some bcryptjs library issue.

Snippet of package.json:

node: v20.11.1
"next": "15.1.7",
"next-auth": "^5.0.0-beta.25",
"bcryptjs": "^3.0.2",

Snippet code: the issue is no matter what I input is always return true of comparing: Image console: Image

D50000 avatar Mar 27 '25 15:03 D50000

Hey, I'd supposed that the value sent to bcrypt.compareSync should be user.password instead of password? It seems you are comparing the input against itself.

ramos-ph avatar Apr 11 '25 19:04 ramos-ph

Hey, I'd supposed that the value sent to bcrypt.compareSync should be user.password instead of password? It seems you are comparing the input against itself.

Oh my bad, I just realize the logic is not make sense. TYVM~ 🙌

D50000 avatar Apr 12 '25 03:04 D50000