title: After user login change links from login to logout in Node.js
body: <p>I am using passport.js for user authentication, user is successfully logging in.
  and now I try to change the navigation links i.e Login to logout after user successfully logged in.</p>
  
  <p>for that I am using the following middleware in app.js file</p>
  
  <pre><code>  var express=require('express');
  var path=require('path');
  var bodyParser=require('body-parser');
  var cookieParser=require('cookie-parser');
  var passport=require('passport');
  var LocalStrategy=require('passport-local').Strategy;
  var expressSession=require('express-session');
  var app=express();
  require('./db');
      var userModel=require('./models/usermodel');
      var adminModel=require('./models/adminmodel');
  
  app.use(function (req, res, next) {
    res.locals.login = req.isAuthenticated();
    next(); });
  
  
  //Configuring Routes
  var routes = require('./routes/index');
  var register = require('./routes/register');
  var login = require('./routes/login');
  var admin = require('./routes/admin');
  var addblog = require('./routes/addblog');
  var admindashboard = require('./routes/admindashboard');
  var adminviewblog = require('./routes/admin-view-blog');
  var viewblog = require('./routes/view-blog');
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'ejs');
  
  // app uses configuration
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  app.use(express.static(path.join(__dirname, 'routes/uploads')));
  app.use(expressSession({ secret: 'keyboard catoard cat' }));
  app.use(passport.initialize());
  app.use(passport.session());
  
  
  app.use('/', routes);
  app.use('/register', register);
  app.use('/login', login);
  app.use('/admin', admin);
  app.use('/addblog', addblog);
  app.use('/admindashboard', admindashboard);
  app.use('/admin-view-blog', adminviewblog);
  app.use('/view-blog', viewblog);
  
  //passport configuration
  
     /*=======passport configuration========*/
  passport.use("userss", new LocalStrategy(userModel.authenticate()));
  passport.use("adminn", new LocalStrategy(adminModel.authenticate()));
  passport.serializeUser(function(user, done){
      done(null, user.id);
      });
  passport.deserializeUser(function(id, done){
      userModel.findById(id, function(err, user){
          done(err, user);
          });
  
      });
      passport.deserializeUser(function(id, done){
      adminModel.findById(id, function(err, user){
          done(err, user);
          });
  
      });
  
  
  //create server
  app.listen(3000, function(){
      console.log('Server is running  localhost:3000');
      });
  </code></pre>
  
  <p>and in ejs template</p>
  
  <pre><code>&lt;% if login %&gt;
          &lt;li&gt;&lt;a href="/logout"&gt;Logout&lt;/a&gt;&lt;/li&gt;
          &lt;% else %&gt; 
           &lt;li&gt;&lt;a href="/login"&gt;Login&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="/register"&gt;Register&lt;/a&gt;&lt;/li&gt; 
          &lt;% endif %&gt;
  </code></pre>
  
  <p>But its not working. 
  the page showing the following errors.</p>
  
  <pre><code>SyntaxError: Unexpected identifier in F:\saurabh_sharma\nodejs\blogsystem\views\index.ejs while compiling ejs
     at Function (native)
     at Object.Template.compile (F:\saurabh_sharma\nodejs\blogsystem\node_modules\ejs\lib\ejs.js:464:12)
  </code></pre>
  
  <p>I googled this problem but didn't find the solution.</p>
  
  <p>If someone have idea about this please let me know.</p>
  
  <p>Thanks.</p>