nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

Error: Authentication credentials invalid following `server.js` example. #132

Open MontoyaAndres opened 4 years ago

MontoyaAndres commented 4 years ago

I'm just trying to log in as a normal user, but I have this error: Error: Authentication credentials invalid. I'm following the server.js example

In the client, when an user uses the /login post method, it executes:

connection.connect(() => {
      connection.login(
        {
          credentials: {
            user: "andresmontoyafcb@gmail.com",
            pass: "supersecretpassword"
          }
        },
        err => {
          console.error(err);
        }
      );
    });

The server receives this in the onAuth function, like this:

const isEmail = USERS.some(user => user.email === auth.username);
const isPassword =
      auth.method === "CRAM-MD5"
        ? auth.validatePassword(password)
        : USERS.some(user => user.password === auth.password);

// If the email and the password exists in the array `USERS`, return the information
if (isEmail && isPassword) {
  return callback(null, { user: auth.email });
}

// If not, show me this error
return callback(new Error("Authentication failed"));

But, when I ingress the right information, it does not return me the callback function... It shows me:

Screenshot_2019-08-28_14-29-45

This is the complete code.