Open chiragbatra29 opened 7 years ago
Please use ``` to format your code, see https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
It seems that your provided code is not related to the issue, please provide more information.
I'm using Express 4.15.2, and it's working fine. To hazard a guess, you're not correctly importing passport, or you're using passport in a file (looking at the export) which doesn't have passport included.
To fix:
const passport = require("passport");
Then in your express, add the passport stuff, I've included what I'm using for reference:
app.use(session({ secret: 'mysecret', // session secret resave: true, saveUninitialized: true })); app.use(passport.initialize()); app.use(passport.session());
This is an express configuration issue, and not a passport issue.
TypeError: passport.initialize is not a function whenever i am using express 4.15.2. even after using below version.
exports.login = function(req, res){ var Name = req.body.name; var Email = req.body.email; var Password = req.body.password; User.findOne({ name: Name, email: Email, password: Password}, function(err, user){ if(err){ console.log(err); return res.status(500).send(); } if(!user){ return res.status(400).send("User Not Exist "+" name:"+Name+" email:" +Email ); } console.log('hi'); return res.status(200).send(user); }) res.redirect('/users/' + req.user.username); }