jaredhanson / jaredhanson/passport

user undefined after login

Open
#643 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
23.5k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

I am trying to authenticate user ,when i try to login user after successful verification using `req.logIn` but it doesn't worked

router.post('/login', function(req, res, next) {
passport.authenticate('login',function (cb,data) {
//user verfication success
if(data){
req.logIn({user:"shamon"},function(err,result){
console.log("result",result,err)
res.send('login success');
});
}
})(req,res,next);
});

this `console.log("result",result,err)` gives me `undefined,undefined`

when i log `req.user` after logged i got undefined error

Contributor guide

Open the contributing guide

Research direction

Start at the router.post('/login') entry point and read the req.logIn API and its callback contract. Reproduce the login flow, inspect why req.user and the callback values are undefined, and consider the issue done when the route reliably establishes the authenticated user or documents the missing context needed to diagnose it.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript, node.js
Domain
authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.