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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:21:22+00:00 2026-06-12T06:21:22+00:00

I have followed the code here – > https://github.com/jaredhanson/passport-local/tree/master/examples/express3 for add local authentication for

  • 0

I have followed the code here – > https://github.com/jaredhanson/passport-local/tree/master/examples/express3 for add local authentication for users.

The problem is when I try to add users,

So I created this route

app.get('/signup', function(req,res){
  res.render('/signup');
});

app.post('/signup', function(req,res){
  var body = req.body;
  users.push(body);
  res.redirect('/');
});

Then the page w the form It’s

form(method='POST', action='/signup')
 input(type='text', name='username', placeholder='username')
 input(type='text', name='password', placeholder='password')
 button.btn Register

The dummy DB It’s the one on the example

users = [
  {id:1, username: 'test', password:'papapa'}
];

So when I send the info w the form, all goes ok, but when I try to log in with the new created user, tells me “Error: failed to serialize user into session”

the serializeUser is this

passport.serializeUser(function(user, done) {
  done(null, user.id);
});

passport.deserializeUser(function(id, done) {
  findById(id, function (err, user) {
    done(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-12T06:21:23+00:00Added an answer on June 12, 2026 at 6:21 am

    The user being pushed in the POST /signup route will not have an ID, which the examples serialization code expects.

    Change it to something like this, and it should work.

    app.post('/signup', function(req,res){
      var body = req.body;
      body.id = users.length;
      users.push(body);
      res.redirect('/');
    });
    

    (Note that this is an example only, and not recommended for “real” apps.)

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

Sidebar

Related Questions

I have followed the instructions found at http://code.google.com/p/pubsubhubbub/wiki/DeveloperGettingStartedGuide to setup a hub. When I
I have followed the code example here toupper c++ example And implemented it in
I followed the code here: http://drumcoder.co.uk/blog/2010/apr/09/django-reset-password/ as well as here: http://shrenikp.webs.com/apps/blog/entries/show/7133721-implement-forgot-password-on-customer-ui- and here: http://blog.montylounge.com/2009/07/12/django-forgot-password/
I have a file containing some lines of code followed by a string pattern.
I have got this code and I am trying to understand the convention followed,
Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I have followed his popular tutorial to connect Android to MySQL: http://www.helloandroid.com/tutorials/connecting-mysql-database It is
I followed Jonathan's code from here ( MPI_Bcast a dynamic 2d array ) to
I am new to rails so could use some help here. I have followed
I have followed the code provided by Google concerning implemeting a Web Map Activity,

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.