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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:46:59+00:00 2026-05-27T07:46:59+00:00

Using node.js / expressjs / mongoose / mongoose-auth / everyauth. All versions are up

  • 0

Using node.js / expressjs / mongoose / mongoose-auth / everyauth. All versions are up to date.

I’m trying to use a database table to whitelist users by email address during development, but I want the primary method of auth to be facebook. I’m looking to have mongoose-auth only create the account if the facebook email is found in alpha_whitelist. This creates accounts as expected for addresses that are in the table, but it times out and crashes the server if the user is not in the whitelist.

findOrCreateUser:   function (sess, accessTok, accessTokExtra, fbUser) {
    var promise = this.Promise(),
        User = this.User()();
        // TODO Check user in session or request helper first
        // e.g., req.user or sess.auth.userId
        User.findOne({'fb.id': fbUser.id}, function (err, foundUser) {
            if(foundUser)
                return promise.fulfill(foundUser);
            alpha_whitelist.findOne(
                {email: fbUser.email},
                function(err,doc) {
                    if(doc) {
                        console.log("CREATING");
                        User.createWithFB(fbUser, accessTok, accessTokExtra.expires, function (err, createdUser) {
                            console.log(err,createdUser);
                            if (err) return promise.fail(err);
                            return promise.fulfill(createdUser);
                        });
                    } else {
                        console.log('Denied');
                        //not sure what to do here... i need to break the auth chain and redirect the user back to '/'
                    }
                });
        });
        return promise;
    }

It seems that no matter what I put there, it fails and crashes the server. I’m clearly missing something. Any help would 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-05-27T07:47:00+00:00Added an answer on May 27, 2026 at 7:47 am

    I haven’t tested this, but I’m sure you just need to return the Promise just as the other code blocks are doing

    else {
        console.log('Denied');
        return promise.fail('Denied');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a node.js app using express and mongoose-auth. When I run my app,
I'm using node.js with Express and connect-auth to authenticate users. This is the verification
I am using node.js + express.js + everyauth.js. I have moved all my everyauth
i'm using node 0.4.11 express 2.4.6 mongodb 1.8.3 mongoose 2.1.2 connect-mongodb 1.0.0 and trying
I'm trying to evaluate an xml node using xpath and i'm not sure why
I'm trying to serve long polling requests for 60 secs using node.js. The problem
I am using node.js with express. I read out data from MongoDB with Mongoose
I'm using jade/pug template engine with ExpressJS on Node.js. It outputs a html with
Using Jade + Express + Node.js + Mongoose + MongoDB for my app, but
I'm having a problem with Express under Node.js. I'm trying to use sessions 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.