maintain user login status in express.js
- by chenliang
when user login the app the username will be display in the header,
this is my header.jade
div#header_content
input(type='text',name='search',id='globle_search')
span#user_status
if(req.isAuthenticated())
a(class='user_menu_btn',href='home', target='_blank' ) req.user.username
a(class='user_menu_btn',href='logout') Logout
else
a(id='login_btn',href='login',class='user_status_btn') login
run the app i get the error says
ReferenceError: F:\shopping\views\includes\header.jade:4
req is not defined
this is my index route:
app.get('/',index.index);
exports.index = function(req, res){
res.render('index', { title: 'Express' });
};
how to maintain login ststus in the heaedr?
by the way am using passport to login user