4 Replies Latest reply on Jan 12, 2008 2:32 AM by milli

    redirect based on roles

    lsabin

      Hi.

      In my application after the user logs in I want to redirect to a different page based on the user role. This is the relevant portion of my pages.xml:

       <navigation from-action="#{identity.login}">
       <rule if="#{s:hasRole('user')}">
       <redirect view-id="/details.xhtml"/>
       </rule>
      
       <rule if="#{s:hasRole('admin')}">
       <redirect view-id="/home.xhtml"/>
       </rule>
       </navigation>
      




      The first time the user with role 'user' logs in this navigation rule does not work and the user gets redirected to the home.xhtml page. But if I logout and log in again it works fine and redirects to details.xhtml.

      Could someone explain this behaviour?

      Thanks.

        • 1. Re: redirect based on roles
          pmuir

          Can you use your debugger to see what roles the user has when the s:hasRole check is run?

          • 2. Re: redirect based on roles
            lsabin

            Hi.

            If i understand correctly the preAuthorizationRoles gets "promoted" to real roles after the s:hasRole is evaluated. That's why the first time the user does not have the role.
            Is there any way to fix this behaviour?

            A silly question, how to debug seam applications? I mean debugging the seam core.

            Regards.

            • 3. Re: redirect based on roles
              milli

              I have similar rules for my login but I get an exception "javax.el.ELException: Function 's:hasRole' not found". But I could have s:hasRole in xhtml pages to do conditional rendering. I am using Seam 1.2.1. Any ideas?

              But if it does not work like you mentioned then it is not of much use for me either.

              • 4. Re: redirect based on roles
                milli

                 

                "milli" wrote:
                I have similar rules for my login but I get an exception "javax.el.ELException: Function 's:hasRole' not found". But I could have s:hasRole in xhtml pages to do conditional rendering. I am using Seam 1.2.1. Any ideas?

                But if it does not work like you mentioned then it is not of much use for me either.


                Never mind. I found in another thread that it was a bug in 1.2.1.