Description
const router = require('express').Router()
const User = require('../models/user.model')
const { body, validationResult } = require('express-validator')
const passport = require('passport')
router.get('/login', ensureNotAuthenticated, async(req, res, next) => {
res.render('login')
})
router.post('/login', ensureNotAuthenticated,
passport.authenticate('local', {
successReturnToOrRedirect: '/',
failureRedirect: "/auth/login",
failureFlash: true
}))
if for example a user tries to access a protected route, say 'auth/profile', he gets redirected to the log in page, but on successfully logging in, he gets redirected to the route specified in 'successReturnToOrRedirect'. I was using passport 0.4.1 and there, it redirected back to the previous protected route after the user has successfully logged in