Stormpath User information

ok this is my router code and I am trying to access user account information when they are on the home page. So far no luck... what am I doing wrong here?

// Render the dashboard page.
router.get('/home', function (req, res) {
  if (!req.user || req.user.status !== 'ENABLED') {
    return res.redirect('/login');
  }



  console.log('User:', req.user.email, 'just accessed the /home page!');


  //user: req.user

  res.render('home', {
    title: 'Home',
    user:req.user.username
    }

  );


});

Your example looks correct, though I would assign the entire user object in the render call (right now you're just passing the username).

So if you placed this in routes/index.js

// Render the 'home' page if logged in and account is not disabled
router.get('/home', function (req, res) {
  if (!req.user || req.user.status !== 'ENABLED') {
    return res.redirect('/login');
  }

  res.render('home', {
    title: 'Home',
    user: req.user
  });

});

Then the view in views/home.jade would look like this:

html
  head
    title=title
  body
    p Hello, #{user.username}

the issue (it appears) is that you don't have the loginRequired middleware set on your route. You should modify your function signature to:

router.get('/home', stormpath.loginRequired, function(req, res) {
  ...
});

This will force the user to be evaluated correctly =)