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.
any ideas?
ok, issue policies in sails applied controllers, not views.
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] }