here is my complete code
var express = require(\'express\'),
app = express(),
mongoose = require(\'mongoose\'),
bodyParser = require(\'body-parse
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.
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.