Using the Acegi Taglib

/ Published in: HTML
Save to your folder(s)

Copy this code and paste it in your HTML
  1. <g:isLoggedIn>
  2. Only logged users (no matter witch roles) will see this text. This is useful to build the "Welcome ..." text and the logout link!
  3. </g:isLoggedIn>
  5. <g:isNotLoggedIn>
  6. Only anonymous users will see this. This is nice to build your "login" or "registration" link!
  7. </g:isNotLoggedIn>
  9. <!-- Let's pretend we are logged as our 'god' user -->
  10. <g:loggedInUserInfo field="username"/> <!-- will show 'god' -->
  11. <g:loggedInUserInfo field="email"/> <!-- will show '[email protected]' -->
  12. <g:loggedInUserInfo field="userRealName"/> <!-- will show 'god almighty' -->
  14. <g:ifAllGranted role="ROLE_ADMIN,ROLE_USER">
  15. This information will be available for admins whom have the ROLE_USER associated either.
  16. </g:ifAllGranted>
  18. <g:ifAnyGranted role="ROLE_ADMIN,ROLE_USER">
  19. This information will be available for any logged admin or user.
  20. </g:ifAnyGranted>
  22. <g:ifNotGranted role="ROLE_ADMIN">
  23. All sessions that have the ROLE_ADMIN associated will not see this message!
  24. </g:ifNotGranted>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.