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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -