Good morning,
I have the same problem as the person who opened the following topic : Using argon2 in custom database - Auth0 Community
Would anyone have the solution please?
Here is the error and my code:
Code generated an uncaught exception: TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
function login(email, password, callback) {
const MongoClient = require('mongodb').MongoClient;
const argon2 = require('argon2');
const client = new MongoClient('mongodb+srv://XXXXX.mongodb.net/?retryWrites=true&w=majority');
client.connect(function (err) {
if (err) return callback(err);
const db = client.db('test');
const users = db.collection('users');
users.findOne({ email: email }, function (err, user) {
if (err || !user) {
client.close();
return callback(err || new WrongUsernameOrPasswordError(email));
}
console.log(argon2);
argon2.verify(user.password, password)
.then(() => {
console.log('Password ok.');
})
.catch((error) => {
console.log('Password NOK.');
});
/*if(password === user.password){
return callback(null, {
user_id: user._id.toString(),
nickname: user.nickname,
email: user.email
});
}*/
});
});
}