Why wont my passport be executed?
Current output:
routing post login
using passport
and nothing more. logging in
isnt even executed.
code from server.js ( only that has to do with passport).
var Account = require('PATH/app/models/Users.js');
var passport = require("passport");
var LocalStrategy = require('passport-local').Strategy;
app.use(passport.initialize());
// persistent login sessions
app.use(passport.session());
passport.use(new LocalStrategy(Account.authenticate()));
passport.serializeUser(Account.serializeUser());
passport.deserializeUser(Account.deserializeUser());
router.post('/login', function(req,res) {
console.log("routing post login");
console.log(req.body);
var username = req.body.username;
var password = 0;
console.log("using passport");
passport.use(new LocalStrategy(
function(username, password, done) {
console.log("logging in");
if (username == "admin") {
var user = {username: "admin"};
if (!user) {
return done(null, false);
}
/* if (!user.verifyPassword(password)) {
console.log("failing user verify");
return done(null, false);
}*/
console.log("authenticate local");
passport.authenticate('local')(req, res, function () {
res.redirect('/');
console.log("redirecting");
console.log("returning done");
res.json({type: 'success'});
return done(null, user);
});
}
}
));
});
via maria
No comments:
Post a Comment