Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
In passport not getting req.user value in node js

I have an app in node js with javascript and I am trying to get the req.user but it's coming. Below is the code example which I am using

const app=express();
var bodyparser=require('body-parser');
var session=require('express-session');
var passport= require('passport');
var saml= require('passport-saml');
app.use(bodyparser.json);
app.use(bodyparser.urlencoded({extended:false});
app.use(session ({secret:'secretval',
resave: false,
saveUninitialized: true,}));
app.use(passport.initialize({}));
app.use(passport.session({}));

And I have below methods,

app.get('/login',passport.authenticate('samlstrategy',{session:true}),(req,res)=>{
res.redirect('myurl');
console.log('logged in user is as'+req.user);
return;
}

app.get('/login/callback',passport.authenticate('samlstrategy',{session:true}),(req,res)=>{
res.redirect('myurl');
return;
}

When I am invoking the url for /login it's working and user is getting authenticated by passport api.but I am not getting the user details in request. How can I get the user in req object.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If user is a get parameter then you forgot query after req

Use

req.query.user
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!