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 8970777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:47:24+00:00 2026-06-15T17:47:24+00:00

I have working example with express 2.* but now I am moving to version

  • 0

I have working example with express 2.* but now I am moving to version 3.*. The problem is authentication with facebook which causes some problems. All works until the everyauth makes the GET request to facebook and then returns errror:

500 Error: WARNING: You are trying to access the attribute/method configured by `findUserById`, which you did not configure. Time to configure it.

Here is the app.js code

/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes')
  , config = require('./conf/config.js')
  , user = require('./routes/user')
  , file = require('./routes/file')
  , http = require('http')
  , path = require('path')
  , everyauth = require('everyauth');

var UserService = require(__dirname + '/db/mongodb/UserService').UserService;

everyauth.facebook
  .appId(config.fb.appId)
  .scope('email')
  .fields('id,name,email')
  .appSecret(config.fb.appSecret)
  .findOrCreateUser(function(session, accessToken, accessToExtra, fbUserMetadata) {
    var promise = this.Promise();
    UserService.findOne({ email: fbUserMetadata.email }, function(err, user) {
      if (!user) {
        // Try to register user
        fbUserMetadata['accessToken'] = accessToken;
        UserService.save(fbUserMetadata);
        user = fbUserMetadata;
      }
      return promise.fulfill(user);
    });
    console.log(fbUserMetadata);
    return promise;
  })
  .findUserById(function(userId, cb) {
    console.log('findByUserId called');
    UserService.findOne({ id: userId }, function(err, user) {
      return cb(err, user);
    });
  })
  .redirectPath('/');

var app = express();

app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.compress());
  app.use(express.json());
  app.use(express.urlencoded());
  app.use(express.methodOverride());
  app.use(express.cookieParser('your secret here'));
  app.use(express.session());
  app.use(everyauth.middleware(app));
  app.use(app.router);
  app.use(require('less-middleware')({ src: __dirname + '/public' }));
  app.use(express.static(path.join(__dirname, 'public')));
});

everyauth.debug = true;
//everyauth.helpExpress(app);

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

//console.log(everyauth.facebook);

app.get('/', routes.index);
app.get('/users', user.list);

app.get('/file', file.index);
app.post('/upload', file.upload);

http.createServer(app).listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));
});

To fix this add the lines:

everyauth.everymodule.findUserById(function(userId, cb) {
    console.log('findByUserId called');
    UserService.findOne({ id: userId }, function(err, user) {
      return cb(err, user);
    });
  });
  • 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-06-15T17:47:25+00:00Added an answer on June 15, 2026 at 5:47 pm

    Make the call to findUserById on everyauth.everymodule instead of on everyauth.facebook:

    everyauth.everymodule.findUserById(function(userId, cb) {
        console.log('findByUserId called');
        UserService.findOne({ id: userId }, function(err, user) {
            return cb(err, user);
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have a working example of OAuth authentication for twitter with Android? I
Sorry for repost but I have a better working example of data that reflects
I'm working on setting up authentication with connect-auth on express & mongoose but there
Does anyone out there have a working example of the Facebook live stream plugin
Does anyone have a working example of a video player built using Qt phonon?
Does anybody have an example of working with database using Visual C++ and OLEDB?
I have spatial search working well with SOLR 3.2 Example : ?q=*&fq={!geofilt pt=48.86761919303129,2.3527903735351856 sfield=coordinates
I am working with this example to try and learn Sencha Touch. I have
I'm working through the NerdDinner ASP.NET MVC 1.0 example. I have it all working
I have this simple example I can't seems to get working : MERGE INTO

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.