Sushant Bhatnagar
Sushant Bhatnagar

Reputation: 3784

Dynamically change menu according to user role in Grails?

I want to display different menu according to login user . If user is client then display different menu otherwise show different menu.

I have one table User which is used to authenticate user , Client table which hold the userId as foreign key . Then how we determine whether user is client or not?

Another there is any way to add controller for menu?

Upvotes: 0

Views: 1001

Answers (1)

zoran119
zoran119

Reputation: 11317

One of the best ways would be to use Spring Security plugin. Once setup (which is easy and there is good documentation around) you can control content based on user/roles in a couple ways:

  • In the controller - pass different menu options to the view based on the output of ifAllGraanted('ROLE_ADMIN') function
  • Directly in the view - <sec:ifAllGranted roles="ROLE_ADMIN">

More info here: http://grails-plugins.github.com/grails-spring-security-core/docs/manual/guide/6%20Helper%20Classes.html

Upvotes: 1

Related Questions