title: How to get the profile of current user in node js
body: <p>I am using MEAN Stack and mongoose. Using passport for authentication. I want to get the currently logged in user and display his details. For example if I am logged in and if I go to the profile page I want to get my details. There were only few resources on the internet.</p>
  
  <blockquote>
    <p>Login.js (passport and routes are here)</p>
  </blockquote>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  var passport = require('passport');
  
  var LocalStrategy = require('passport-local').Strategy;
  
  var User = require('../models/user');
  
  var ConnectRoles = require('connect-roles');
  
  
  router.get('/', function(req, res, next) {
  
  res.render('Login', { title: 'Login' });
  });
  
  passport.serializeUser(function(user, done) {
  
      done(null, user._id);
  });
  
  passport.deserializeUser(function(id, done) {
  
      User.findById(id, function(err, user) {
  
      done(err, user);
      });
  });
  
  passport.use("/", new LocalStrategy(
  
       function(username, password, done) {
  
          User.findOne({ username: username }, function(err, user) {
  
              if (err) { return done(err); }
              if (!user) {
                  return done(null, false,
                   { message: "No user has that username!" });
              }
              user.checkPassword(password, function(err, isMatch) {
  
              if (err) { return done(err); }
                  if (isMatch) {
  
                      return done(null, user);
                  } else {
                      return done(null, false,
                   { message: "Invalid password." });
              }
          });
      });
  }));
  
  router.use(function(req, res, next) {
  
      res.locals.currentUser = req.user;
  
      res.locals.errors = req.flash("error");
  
      res.locals.infos = req.flash("info");
      next();
  });
  
  router.post("/", passport.authenticate("/", {
  
      successRedirect: "/SubmitSurvey",
      failureRedirect: "/",
      session: false,
      failureFlash: true
  }));
  
  
  router.get("/AdminDatabase", function(req, res) {
  
     res.render('AdminDatabase', { title: 'AdminDatabase' });
  
   });
  
  
  router.get('/CreateSurvey', function(req, res, next) {
  
    res.render('CreateSurvey', { title: 'CreateSurvey' });
  
  });
  
  
  router.get('/SubmitSurvey', function(req, res, next) {
  
    res.render('SubmitSurvey', { title: 'SubmitSurvey' });
  
  });
  
  
  router.get('/profile', function(req, res, next) {
  
    res.render('profile', { title: 'profile' });
  
  });
  
  
  router.get("/Logout", function(req, res) {
  
      req.logout();
  
      res.redirect("/");
  });
  
  module.exports = router;
  </code></pre>
  
  <p>How can I do this in nodejs</p>