I have Passport authentication installed in my simple express application and it works fine and I have req.user displaying on my index page, for example:
<% if (!isAuthenticated) { %>
<a id="signIn" href="/login">Sign In</a>
<% } else { %>
<h3 id="welcomeMsg"><%=user.id%></h3>
<h2 id="userBalance"><%=user.balance%></h2>
<a href="/logout">Log Out</a>
<% } %>
In index.js:
app.get('/', function(req, res){
res.render('index', {
isAuthenticated: req.isAuthenticated(),
user: req.user
});
});
What I want to do is confirm the name of the user who signed up in the client side js file in my shared directory. What will be the easiest and easiest way to make this variable available in this file?
thank
source
share