How to use `callLoginMethod` without getting this error?

I’m trying to add a login to my app and the database of the users is not local. I mean it’s on

The thing is I got this error every time I try to connect:

 Exception while invoking method 'login' Error: Match error: Unknown key in field username
     at exports.check (packages/check/match.js:34:1)
     at [object Object].<anonymous> (packages/accounts-password/password_server.js:250:3)
     at packages/accounts-base/accounts_server.js:471:32
     at tryLoginMethod (packages/accounts-base/accounts_server.js:248:14)
     at AccountsServer.Ap._runLoginHandlers (packages/accounts-base/accounts_server.js:468:18)
     at [object Object].methods.login (packages/accounts-base/accounts_server.js:531:27)
     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1711:12)
     at packages/ddp-server/livedata_server.js:711:19
     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
     at packages/ddp-server/livedata_server.js:709:40
     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
     at packages/ddp-server/livedata_server.js:707:46
     at Session.method (packages/ddp-server/livedata_server.js:681:23)
     at packages/ddp-server/livedata_server.js:551:43
 Sanitized and reported to the client as: Match failed [400]

I guess this error appears because I have nothing in Meteor.users right ?

The call to login is :

        methodArguments: [loginRequest],
        userCallback: callback,

server/cmdb_login.js where the console.log never write anything

Accounts.registerLoginHandler(function(loginRequest) {
  console.log("Accounts.registerLoginHandler has been called it's a server file");

  var accessToken;
  try {
    var rcmacmdb = '';
    switch (process.env.WHERE_ENV) {
      case "lab":
        rcmacmdb = 'lrsmcmdb';
      case "int":
        rcmacmdb = 'irsmcmdb';
      case "prod":
        rcmacmdb = 'rsmcmdb';
        //rcmacmdb = 'unknowrcmacmdb';
        rcmacmdb = ""
    console.log("username:  " + loginRequest.username);
    var response ='POST', '', {
      auth: loginRequest.username + ':' + loginRequest.password

    accessToken = response.headers['access-token'].trim();
  } catch (e) {
    console.log("ERROR in postLoginCmdb");
    return undefined;

I can reach the ip of and connect with my user so the problem is from the code and not the CMDB.

I really hope someone will be able to help me to find what is making this error

Finally I made something else you can delete this one

It’s not deleting itself. By the way what you’ve missed was that you should not use the loginRequest.password property, it used the accounts handler will fail on your custom request.

1 Like