F
F
FeL1ksS2018-02-03 19:02:55
JavaScript
FeL1ksS, 2018-02-03 19:02:55

Redirect and History API?

Hello, please tell me, there is a login / password form and a redirect to a page for registered users only, this page has a button to log out, sends a request to /logout.
On the server, this code

app.get('/adm', function(req, res) {
    res.render('authAdmin', function(err, html) {
        res.send(html);
    });
});
app.post('/adm', passport.authenticate('login', {
    successRedirect: '/adm/dashboard',
    failureRedirect: '/adm',
}));
app.get('/logout', function(req, res, next) {
    req.logout();
    req.session.destroy();
    res.redirect('/adm');
});
app.get('/adm/dashboard', passport.isAuthenticated, function(req, res) {

The redirect works, but with the back button in the browser, I can go back to the "protected page" again, and this is kind of not very good. It is necessary that the user could not return to this page without logging in again.
On the client, you can write location.replace () and then the history will not be saved, but it seems to me that I'm doing something wrong.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question