Search code examples
grailsweblogicspring-security

How to redirect depending of the role with Grails Acegi on weblogic


in my index.gsp, I have this :

<g:ifAnyGranted role="IS_AUTHENTICATED_ANONYMOUSLY">
  <% response.sendRedirect("login/auth"); %>
</g:ifAnyGranted>
<g:ifAnyGranted role="ROLE_ADMIN">
  <% response.sendRedirect("admin/tasks"); %>
</g:ifAnyGranted>
<g:ifAnyGranted role="ROLE_VIEWER_I, ROLE_VIEWER_E">
  <% response.sendRedirect("items/list"); %>
</g:ifAnyGranted>

If I run it on tomcat, that's work fine.

But after a deployment on weblogic 11g, it's not working.

Do you have an idea ?

Thanks a lot


Solution

  • I would recommend doing this in the controller, not the view.

    class SomeController {   
       def springSecurityService   
       def someAction = {
          if (springSecurityService.isLoggedIn()) {
             response.sendRedirect(...)
          }
          else {
             response.sendRedirect(...)
          }
       }
    }