jaredhanson / jaredhanson/passport
login not working.
- Dominant language
- JavaScript
- Stars
- 23.5k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
TypeError: self._verifyTotpCode is not a function
at ../node_modules/passport-2fa-totp/lib/strategy.js:119:22
at
at process._tickCallback (internal/process/next_tick.js:118:7)
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at validateHeader (_http_outgoing.js:503:11)
#Here is my code
passport.use('login', new TwoFAStartegy({
usernameField: 'username',
passwordField: 'password',
codeField: 'code',
passReqToCallback: true,
skipTotpVerification: true
}, function (req, username, password, done) {
// if(NODE_ENV != 'development' && username != 'test@gmail.com')
// return done(null, false, { message: INVALID_LOGIN });
// 1st step verification: username and password
process.nextTick(function () {
console.log('username', username);
request({
headers: {
'email': username,
},
uri: apiStrings.getUserObjByEmailUri,
method: 'GET'
}, function (err, res, body) {
body = JSON.parse(body);
if (err) {
return done(err);
} else if(body.status == 'error' || body.user == null) {
return done(null, false, { message: INVALID_LOGIN });
}
bcrypt.compare(password, body.user.password, function (err, result) {
if (err) {
return done(err);
}
if (result === true) {
return done(null, body.user);
} else {
return done(null, false, { message: INVALID_LOGIN });
}
});
});
});
}));
Contributor guide
Research direction
Start with the reported stack trace at node_modules/passport-2fa-totp/lib/strategy.js:119 and review how passport.use('login') configures TwoFAStartegy. Reproduce the TypeError and ERR_HTTP_HEADERS_SENT behavior with the shown configuration; done requires identifying whether the failure is in Passport or the passport-2fa-totp integration and documenting a reproducible case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100