I am a rookie in nodejs. I am making an e-commerce site using kraken framework and dust template. I want to display Log in and Log out text depending upon the session status. My logout and login functionality is working fine. I want to hide the log-in text when the user has logged in and the logout text when the user has logged out.How can I achieve that? My middleware for checking if a user has logged in is as follows :
app.get('*', function(req, res, next) {
res.locals.user = req.user || null;
next();
});
How can I achieve that using dust-helpers?
At some point, you'll be calling
res.render()with a template and a context object to render.First, you need to pass your user object as part of the context:
Then, in the template, you can see if user exists: