Thursday, 1 June 2017

Page is not properly redirecting with express-session and passport nodejs

I am using passport-local and express-session but my problem is that when I enter an address, after I close the session, I get the problem the browser "Page is not properly redirecting", so what I want to do is redirect to The address / login instead of showing that problem

I'll leave my code

Routes.js

app.get('/index', isLoggedIn, function(req, res) {
    console.log(req.session);
        if (req.session == null  || req.session == undefined)
        {
             res.redirect('/login');
        }
        else
        {
        res.render('index.ejs', {
            user : req.user // get the user out of session and pass to template
        });
    }

    });

app.js

 app.use(session({
     secret  : 'asjdknas',

 }));


 app.use(passport.initialize());
 app.use(passport.session());
 app.use(flash());



via M. Node

No comments:

Post a Comment