Using argon2 custom database

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://');

  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) {
        return callback(err || new WrongUsernameOrPasswordError(email));
      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,

Hi @Lug0x

Welcome to the Auth0 Community!

I’ve checked the tenant of the mentioned post and the user changed the usage of argon2 to bcrypt. This seems as a reasonable change according to my research as bcrypt is better suited for web operations.

I hope this will help you and feel free to ask more questions

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.