Bcrypt error: illegal arguments String unidentified

后端 未结 8 1989
误落风尘
误落风尘 2021-01-17 10:49

here is my complete code

var express = require(\'express\'),
    app = express(),
    mongoose = require(\'mongoose\'),
    bodyParser = require(\'body-parse         


        
相关标签:
8条回答
  • 2021-01-17 11:30

    I have tried the same code for authentication once and got the same error Error: Illegal arguments: string, function.

    But I did not see any issue with the code. The thing is, I had registered two users with the same user name and a different password. Then, when I tried to log in with the user name and one password this error occurred and stopped the server.

    So it seems that you are also facing the same problem. Make sure there are no errors with this stuff if you do not want to have a bug in your code.

    0 讨论(0)
  • 2021-01-17 11:30

    Check the value of user.password before sending it to bcrypt.compare().

    Chances are, you've fetched the user without including the password property, resulting in a value of undefined. This can happen in Sequelize if you set custom attributes or if you're using a scope that excludes props.

    0 讨论(0)
提交回复
热议问题