user257980
user257980

Reputation: 1089

Express js dynamic navigation system

I been trying to find dynamic navigation pluging for Express JS 4.0. Is there any dynamic navigation builder which works with passport.

Basic idea is this

  1. When user is logged in he/she can see the routes where he/she has rights
  2. If user is logged out, he/she can see only. Home-About-Login

Is there any ready made solutions or do I need to add code to include different nav.ejs templates if user is logged in

Upvotes: 0

Views: 388

Answers (1)

Kyle Berry
Kyle Berry

Reputation: 141

I use handlebars as my view-engine so the helpers are going to be different, but what i did was to add a usergroup field to the user, then in the response, pass the usergroup to the render and do something like this with a custom helper

<a href='/'>Home</a>
{{if user.usergroup value=admin}}<a href='/cPanel'>Admin</a>{{/if}}
{{if user.usergroup value=user}}<a href='/Forum'>Forum</a>{{/if}}

Upvotes: 1

Related Questions