5 Replies Latest reply on Nov 16, 2007 9:07 AM by pmuir

    Seam, security and session

    statelessbean

      Hi,

      Let see my app address is like this:
      htttp://localhost:8080/myApp

      when user is logged or not, for default he is redirected to
      htttp://localhost:8080/myApp/home.seam

      When, user login, then is redirected to
      htttp://localhost:8080/myApp/pages/system.seam

      ../pages/ is secured area

      and here is my question!
      When we write again:
      htttp://localhost:8080/myApp user is redirected to our "home.seam" page.

      How can I redirect user to
      htttp://localhost:8080/myApp/pages/system.seam when he is logged and he write htttp://localhost:8080/myApp

        • 1. Re: Seam, security and session
          pmuir

          Use a page action on /home.xhtml to check login and issue a redirect using FacesManager if they are.

          • 2. Re: Seam, security and session
            statelessbean

             

            "pete.muir@jboss.org" wrote:
            Use a page action on /home.xhtml to check login and issue a redirect using FacesManager if they are.


            Can u explain, or target me?

            page actions (u mean pages.xml) and u also write about FacesManager, but that 2 different ways.

            I think better way maybe is in pages.xml but don't know how. Can U show me example?

            • 3. Re: Seam, security and session
              pmuir

               

              <page view-id="/home.xhtml">
               <action execute="#{controller.redirectIfLoggedIn}">


              public void redirectIfLoggedIn() {
               // If logged in
               FacesManager.instance().redirect("/secure/home.xhtml");


              • 4. Re: Seam, security and session
                statelessbean

                I done as u said, but page doesn't work properly.

                All app properties names are not visible and other stuff.


                #{messages['login.portal']}
                #{messages['login.login']}


                Here is my code
                <page view-id="/home.xhtml">
                 <action execute="#{sessionAction.redirectIfLoggedIn}" />
                </page>
                



                public void redirectIfLoggedIn() {
                try {
                if (identity.isLoggedIn()) {
                facesContext.getExternalContext().redirect("/mlm/pages/system.xhtml");

                } else {
                facesContext.getExternalContext().redirect("/mlm/home.xhtml");

                }
                } catch (Exception e) { }
                }


                • 5. Re: Seam, security and session
                  pmuir

                  No you haven't, I used FacesManager.