Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Illegal arguments: number, string #7

Open
yddo opened this issue Jan 29, 2018 · 3 comments
Open

Error: Illegal arguments: number, string #7

yddo opened this issue Jan 29, 2018 · 3 comments

Comments

@yddo
Copy link

yddo commented Jan 29, 2018

im having trouble with the comparePassword function,
i try to authenticate via Post and I get a error

Im using the latest npm package

module.exports.comparePassword = function(candidatePassword, hash, callback){ bcrypt.compare(candidatePassword, hash, (err, isMatch) => { if(err) throw err; callback(null, isMatch); }); }

@GDuccini
Copy link

GDuccini commented Jun 7, 2018

hi yddo . do you solved it?

@andrzuk
Copy link

andrzuk commented Jun 13, 2018

I solved it in this way:

app.post('/login', function (req, res, next) { var user = {}; db.collection('users', function (err, collection) { collection.findOne({ login: req.body.login, }, function (err, result) { if (result && req.body.password) { if (bcrypt.compareSync(req.body.password, result.password)) { user = result; } } }); }); });

@sameerAhmad9291
Copy link

Just convert login password of user into password.toString().
It worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants