var express = require('express'); var router = express.Router(); const passport = require('passport'); const app = require('../app'); router.get('/login', (req, res, next) => { res.render('accounts/login', { title : "Login", message: req.flash('error') }); }); router.get('/logout', (req, res, next) => { req.logout(); res.redirect("/"); }); router.post('/login', passport.authenticate('local', { failureRedirect: '/auth/login', successRedirect: '/', failureFlash: "Invalid email or password.", }), (req, res, next) => { console.log(req.user); }); module.exports = router;