I have a handler for '/', which redirects to /login.html
. However, even though i'm explicitly calling to redirection, the page that is rendered is STILL index.html.
it's pretty lame behaviour, since I'm expecting A and gets B. How can I solve it?
var app = express();
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: false }));
app.use(passport.initialize());
app.use(passport.session());
MW:
app.use('/', (req, res, next) => {
if (req.user) {
next();
} else {
res.redirect('/login');
}
});
app.post('/login',
passport.authenticate('local', {
successRedirect: '/index.html',
failureRedirect: '/login.html'
})
);
via Chen
No comments:
Post a Comment