Debug in node console
How can i remove console.log for errors like 'User and password are invalid' ?? The debug:false value in config is not working??
Which version are you at? 2.x or 3.x?
2.4
Are you sure that output is coming from this module? If you pass in anything falsy/nothing for debug an empty function should be used, hence you shouldn't see any output.
Additionally, the output 'User and password are invalid' is nowhere to be found.. If you mean 'Missing parameters. "username" and "password" are required' or 'User credentials are invalid', these are both passed to the next handler that you pass to the grant middleware.
So either your backend (model.getUser) is calling console.log or your error handler is, not this module.
Ok, for example, this is the console log:
OAuth2Error: User credentials are invalid at OAuth2Error (/Users/emanuelemoccia/my-project/node_modules/oauth2-server/lib/error.js:30:12) at /Users/emanuelemoccia/my-project/node_modules/oauth2-server/lib/grant.js:228:19 at Query._callback (/Users/emanuelemoccia/my-project/psql2.js:230:13)
and this is my model.GetUser:
`model.getUser = function (username, password, callback) {
connection.query('SELECT id FROM users WHERE email = ? AND pass_word = ?', [username, password],
function (error, results, fields) {
callback(error, results.length ? results[0] : false);
}
);
};`
Yes, that is the error handler middleware. Since it's a middleware, it's only used if you load it yourself (take a look at the redis example). And even if you load it already, that doesn't change that it just calls self.debug which will be a no-op if debug was falsy.
It's likely that you either don't use the error-handling middleware provided by this module, but the default error handler provided by express (or whatever framework you use).
Try the following: Try to output something through the internal debug function of the OAuth server after instanciating it, like this:
var oauth = oauthserver({
// ...
debug: false // or null, or undefined, or not specified at all
});
oauth.debug('this is a test');
If you don't see this is a test on your terminal after running the app, the output you see is not coming from this module, but from another error handler down the middleware chain.
If that's the case either use the error handler provided by this module as shown in the redis example or write your own, as documented by your framework (for express see here and here).
I Solved, you're great thank's a lot.