Wednesday, 10 May 2017

nodejs session if login succes

I working on a code to handle passport login session if login success so I created this function

var session = function (req, res) {

  sess = req.session;
//In this we are assigning email to sess.email variable.
//email comes from HTML page.
  sess.email=req.body.email;
  res.end('done');
};

and and i added the session function like that from

app.post('/signin', passport.authenticate('local-signin',  { successRedirect: '/dashboard' ,
                                                    failureRedirect: '/signin'}
                                                    ));

to

app.post('/signin', passport.authenticate('local-signin',  { session ,
                                                    failureRedirect: '/signin'}
                                                    ));

but i get this error

Cannot POST /signin

when i run my code to view session

app.get('/about', function (req, res, next) {
  sess=req.session.email;
  sess.email;
  res.write('<h1>Hello '+sess.email+'</h1>');

  res.end('<a href="+">Logout</a>');
});



via dark night

No comments:

Post a Comment