Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7415779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:22:01+00:00 2026-05-29T07:22:01+00:00

I am a newbie of node.js and everyauth. While I just playing around everyauth

  • 0

I am a newbie of node.js and everyauth. While I just playing around everyauth I have realized that everyauth.user works in jade views but I couldnt get req.user work inside page callbacks.

/**
 * Module dependencies.
 */


var express = require('express')
  , routes = require('./routes')
  , everyauth = require('everyauth')
  , Promise = everyauth.Promise
  , util      = require('util')
  , models = require('./models');



//Everyauth setup

everyauth.twitter
  .consumerKey('XXX')
  .consumerSecret('XXX')
  .findOrCreateUser(function(session, accessToken, accessTokenSecret, twitterData){
    var promise = new Promise();
    models.findOrCreateTwitterUser(twitterData,promise);
    return promise;
  })
  .redirectPath('/');

var app = module.exports = express.createServer();
// Configuration

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.static(__dirname + '/public'));
  app.use(express.cookieParser());
  app.use(express.session({secret:"Iam james bond"}));
  app.use(express.methodOverride());
  //app.use(app.router);  
  app.use(everyauth.middleware());
});

app.configure('development', function(){
  everyauth.debug = true;
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
});

app.configure('production', function(){
  app.use(express.errorHandler()); 
});

// Routes

app.get('/', function(req, res){
  if(req.loggedIn){
    console.log(req.user); //<--This is always undefined
  }
  console.log("index");
  res.render('index', { title: 'Welcome to Chat app' });
});

//Helpers
everyauth.helpExpress(app);

app.listen(3000);
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);

Here is the problematic part

app.get('/', function(req, res){
  if(req.loggedIn){
    console.log(req.user); //<--This is always undefined
  }
  console.log("index");
  res.render('index', { title: 'Welcome to Chat app' });
});

It seems I am missing some point. The weird part is req.loggedIn works as expected but somehow everyauth don’t populate user data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:22:02+00:00Added an answer on May 29, 2026 at 7:22 am

    I’ve been having issues with everyauth req.user with the latest versions. What I do is I use “req.session…”. So If I want to get the user while under the facebook oauth, I’d use req.session.auth.facebook.user.id, and this gives me the users Id.

    console.log(req.session) and from there extract whatever information you want to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm newbie about node.js and mongodb. I have already installed mongodb, but I can't
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
Newbie question: I just installed VisualSVN Server and created a repository. I noticed that
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I'm a Mac newbie and just upgraded to Node.js 0.67. After running node, the
I'm a newbie. I'm using a browser plugin that hits my node server, and
Just another Rails newbie with a problem. I have some Javascript (dynamic) in a
I am a newbie to Hadoop / Hive and I have just started reading
I want to make in a TreeView (winforms) that each node will have in
I am a newbie to the Node.js, Mongoose and Expressjs. I have tried to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.