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

  • Home
  • SEARCH
  • 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 8867769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:07:13+00:00 2026-06-14T17:07:13+00:00

I am using ExpressJS and PassportJS’s Facebook strategy to try and perform some conditional

  • 0

I am using ExpressJS and PassportJS’s Facebook strategy to try and perform some conditional redirects on the authentication callback that should be called when certain properties are missing.

My User Schema:

var UserSchema = new Schema({
  id: ObjectId,
  uid: String,
  facebookToken: String,
  username: String,
  password: String,
  salt: String,
  firstName: String,
  lastName: String,
  email: String,
  birthday: Date,
  gender: String,
  location: String,
  phone: Number,
  verifiedPhone: Boolean,
  interests: {
    culture: Boolean,
    food: Boolean,
    business: Boolean,
    family: Boolean,
    learning: Boolean,
    sports: Boolean,
    movies: Boolean,
    music: Boolean,
    events: Boolean,
    nightlife: Boolean,
    health: Boolean,
    beauty: Boolean,
    fashion: Boolean,
    motoring: Boolean,
    electronics: Boolean,
    groceries: Boolean,
    travel: Boolean,
    decor: Boolean
  },
  weeklyNotifcation: Number,
  weeklyNotificationSent: Number,
  created: {type: Date, default: Date.now}
});

My Callback:

app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/login' }), function(req, res) {
  User.findOne({uid: req.session.uid}, function(err, user) {
    if(user.email || user.location || user.phone || user.location == undefined) {
      res.redirect('/register');
    } else {
      res.redirect('/');
    }
  });
});

The data is stored into mongo after /auth/facebook is called. I check the DB against using the session and check to see if it undefined as it will not return the fields since they weren’t stored in the DB. The callback fails and returns no data received.

Any help will be appreciated.

  • 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-14T17:07:15+00:00Added an answer on June 14, 2026 at 5:07 pm
    if(user.email === undefined || user.location === undefined || user.phone === undefined || user.location === undefined) {
    

    is probably what you meant. Also, you should probably check the err variable to see if there are errors.

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

Sidebar

Related Questions

I am trying to make a web app using ExpressJS and Coffeescript that pulls
I'm using expressjs to serve json. If I try to res.end() with an object
Scenario I have a Node.JS service (written using ExpressJS ) that accepts image uploads
I'm using expressjs along with nowjs, I'm binding some events to the now object
I'm having some issues in validating things using expressjs and mongodb. This is the
I'm using ExpressJS with normal HTML templates (no Jade or similar template engines). Since
I'm using ExpressJs with Node.js and have put all my routes into a 'routes'
I'm using Expressjs w/ node.js and I have a route like this: users.init(app.db, function()
I'm using nodejs w/ expressjs on a Mac and the static files (css/js/img) for
I have a basic expressjs app (using jade), but I am having trouble rendering

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.