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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:04:11+00:00 2026-06-14T02:04:11+00:00

I am getting an undefined function error when trying to log a user in

  • 0

I am getting an undefined function error when trying to log a user in after creating their account via Mongoose…

TypeError: undefined is not a function
at /node_modules/passport/lib/passport/http/request.js:44:48
at pass (/node_modules/passport/lib/passport/index.js:240:14)
at Passport.serializeUser (/node_modules/passport/lib/passport/index.js:242:5)
at IncomingMessage.req.login.req.logIn (/node_modules/passport/lib/passport/http/request.js:43:29)
at Promise.<anonymous> (/routes/index.js:33:25)
at Promise.addBack (/node_modules/mongoose/lib/promise.js:120:8)

My register function in routes/index.js looks like this:

exports.register = function (req, res) {
// Generate salt
Common.bcrypt.genSalt(function(err, salt) {
    req.body.salt = salt;
    // Generate hash
    Common.bcrypt.hash(req.body.password, salt, function(error, hash) {
        req.body.hash = hash;
        // Remove clear text password
        delete req.body.password;
        // Save new user
        new Model.User(req.body).save(function(err, user) {
            console.log(err);
            console.log(req);
            if (user) {
                req.login(user);
                req.redirect('/');
            } else {
                res.json(false);
            }
        });

    });
 });

Any ideas?

  • 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-14T02:04:12+00:00Added an answer on June 14, 2026 at 2:04 am

    If you have a look at node_modules/passport/lib/passport/http/request.js, line 44 column 48 you will see that the function done is being invoked. The error tells you that undefined is not a function, so done is not defined. If you look on line 29 of the same file, you will see that done is a parameter you are supposed to pass to the req.login function. In other words, it’s expecting a callback and you are not providing one. Maybe something like this:

    if (user) {
      req.login(user, function(err) {
        if (err) {
          return req.send('FAILBOAT!');
        }
        return req.redirect('/');
      });
    }
    

    While I use passport, I don’t call req.login directly so I’m not 100% certain on the implications of the code above. I’ll also point out that I do all of the bcrypt stuff in my user model, which seems like a cleaner way to approach that aspect of the problem.

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

Sidebar

Related Questions

QUESTION: Why am I getting Call to undefined function prepare() error ? How can
Why am I getting an undefined reference error using gcc? I am trying to
I am getting a JavaScript error when trying to use the JQGrid: Message: 'undefined'
I am trying to call cplus_demangle() function from libiberty.a, but I am getting undefined
I'm getting undefined for some reason when I try to return the html via
I've been trying to compile my project and I'm getting undefined reference errors. eg.:
I am getting JQUERY undefined error. Do you have any idea (code below). <%@
I'm getting an Undefined Instruction error while running an embedded system, no coprocessor, no
Why am I getting an undefined label error in following code? (I am leaving
I am getting an undefined index error message on server side when i am

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.