node.js - Express passport check if user connected, in html -
in web app have nav bar login button.
but when user connected (passport), want alter "login" "logout" can't check if user connected.
this code nav.html
<nav> <ul class="nav navbar-nav"> <li><a href="/home" title="home">home</a></li> <li><a href="/contact" title="contact">contact</a></li> <li><a href="/about" title="about">about</a></li> {{ req.app.get('login') }} {% if req.app.get('login') %} <li><a href="/logout" title="logout">logout</a></li> {% else %} <li><a href="/login" title="login">login</a></li> {% endif %} </ul> </nav>
-
app.js app.use(function (req, res, next) { req.app.set('login', req.isauthenticated()) //edit next(); });
i tried straight set 'login' @ true or false, in nav.html
it's still not accessible.
if 1 has idea?
if you're using app.get()
syntax value, need utilize app.set()
syntax set value instead of attaching app
object.
html node.js express passport.js swig-template
No comments:
Post a Comment