node.js - Auth/Session not working on one page in Sails with Passport -


i have used passport manage authentication in sails. working bar 1 odd issue. if check user in order modify nav bar

<ul class="nav navbar-nav navbar-right">             {{#if user}}                 <li>{{ user.username }}</li>                 <li><a href="/logout">logout</a></li>                 user!             {{else}}                 <li><a href="/login">login</a></li>             {{/if}}         </ul> 

the log in , go / there nothing there. when go /login or /logout, both of use same template , share code above, both conditions being met.

screenshot

any ideas?

ok, issue policies in sails applied controllers, not views.

sails docs

the solution create pages controller, route method home page view , apply following policy it. passes passport doesn't restrict access. pagecontroller.js

    module.exports = {     home: function (req, res) {         res.view();     } }; 

policies.js

    '*': ['passport'],    pagecontroller: {     '*': ['passport', true]   } 

Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

jquery - jqGrid update specific column data with out refreshing the entire column? -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -