maintain user login status in express.js

Posted by chenliang on Stack Overflow See other posts from Stack Overflow or by chenliang
Published on 2012-10-12T02:31:40Z Indexed on 2012/10/12 3:37 UTC
Read the original article Hit count: 143

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about node.js

Related posts about session