jaredhanson / passport-local

Username and password authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-local/?utm_source=github&utm_medium=referral&utm_campaign=passport-local&utm_content=about
MIT License
2.73k stars 497 forks source link

jwt malformed message #175

Closed joetidee closed 5 years ago

joetidee commented 5 years ago

Expected behavior

I would expect the message in the http response to match that specified in the done function.

Actual behavior

I receive the following http response:

{"statusCode":401,"error":"Unauthorized","message":"jwt malformed"}
return done(null, false, { message : 'foobar' });

Environment

jaredhanson commented 5 years ago

This package does not process JWTs, so a message of "jwt malformed" suggests that the error is occurring in application-level code, rather than this package. Could you provide any diagnostics that led you to pinpoint this package as the source of the issue?

joetidee commented 5 years ago

This is the full code that I'm running, which is a function that is provided by your package:

const PassportLocalStrategy = require('passport-local').Strategy;

module.exports = new PassportLocalStrategy({
    usernameField: 'email',
    passwordField: 'password',
    session: false,
    passReqToCallback: true,
}, async (req, email, password, done) => {

    try {

        return done(null, false, { message : 'foobar' });

    } catch (err) {

    }
});
joetidee commented 5 years ago

Ok, this error is thrown by jsonwebtoken package