Trofee
Trofee

Reputation: 33

Structuring a navbar that will change based on type of account logged in

I have a web design question that I'm trying to puzzle out. Essentially I'm looking to design a navbar such that it will change what buttons/links are displayed in the navbar based on what type of account is signed in. So if a standard user is signed up they might see:

Site Name | Account Settings | Logout

But if an admin is logged in they would see:

Site Name | Account Settings | Manage Users | Logout

I'm using MEANjs for this website, and I have an idea as to how to implement it, but I'm not positive it will work. Basically in Appname\public\modules I think I can make a 'navbar' module, which will have HTML and a controller. The controller would check what type of user is logged in and with conditional statements display certain links and not others. Then in any of my views I would just include the navbar module as the top item. Would this be a good approach?

Along these lines, I'm having trouble coming up with a way to customize other features based on what type of account is logged in. For instance, I want to do a standard home page for un-logged in users, say another home page for users that are logged in, and a third homepage for admins that are logged in. How should this all be handled with MEANjs in terms of file structure? A bit lost here and looking for some light to be shed, so thanks all. If it helps, here's a screenshot of the current site architecture:

https://i.sstatic.net/WZpHA.png

Upvotes: 2

Views: 66

Answers (1)

user3305961
user3305961

Reputation:

As for me, this is what I will do. I will have 3 tables.

  • Table for role if the user is an admin, superadmin, ordinary user, guest etc.
  • Table for user account.

  • A bridge table for user and their role/s if a user can have more than one role.

Then just check if the user is in a role. Just do some conditional checking.

Based on your example: If an admin is logged in they would see:

Site Name | Account Settings | Manage Users | Logout

I just shared my view about this. I'll leave this work to you. Let me know if you need more help.

Upvotes: 0

Related Questions