Hello. The problem is probably stupid, but I cannot write normal authentication to node js. It is important to do this without express. I found a way to do this using the header, but I did not understand how to apply it to the normal beautiful html form.
1 answer
var passport = require('passport'), LocalStrategy = require('passport-local').Strategy; passport.use(new LocalStrategy({ usernameField: 'email' }, function (email, password, done) { User.findOne({ email: email }, function (err, user) { if (err) { return done(err); } if (!user || !user.authenticate(password)) { return done(null, false); } return done(null, user); }); })); |