5 Replies Latest reply on Mar 25, 2009 1:39 PM by viktor.vra.geus.dk

    Seam login issue

    bashan

      Hi,


      I have a page in which you don't have to be logged in to view it, but there are elements in the page that can be used only if you are logged in. you can navigate to this page from all different places. In my header, I have a login link.
      My question is: is it possible in seam, that by pressing the login linkm user is directed to the login page and after login user is directed back to the page before login was pressed?


      Thanks,
      Guy.

        • 1. Re: Seam login issue
          jnusaira

          yes ... seam's authentication will work like that by default as long as you have these items in your components.xml


               <event type="org.jboss.seam.notLoggedIn">
                    <action execute="#{redirect.captureCurrentView}"/>
               </event>
               <event type="org.jboss.seam.postAuthenticate">
                    <action execute="#{redirect.returnToCapturedView}"/>
               </event>
          

          • 2. Re: Seam login issue
            bashan

            I have already in pages.xml these lines:


               <event type="org.jboss.seam.security.notLoggedIn">
                   <action execute="#{redirect.captureCurrentView}"/>
               </event>
               <event type="org.jboss.seam.security.loginSuccessful">
                   <action execute="#{redirect.returnToCapturedView}"/>
               </event>



            I added this one:


            <event type="org.jboss.seam.postAuthenticate">
                      <action execute="#{redirect.returnToCapturedView}"/>
                 </event>



            But it seems to be not working.


            When I get to a page where login is required, I am redirected to login page, then after login I go back to the previous page. this is ok and it used to work for me before.


            What I want is when used in a page that DOESN'T require a login and press the login button, to go to the login page and then move back to the page before the login.


            Should this component: org.jboss.seam.postAuthenticate present this behavior? Should I do anything else, because currently it seems like it is not working...


            Thanks,
            Guy.





            • 3. Re: Seam login issue
              jnusaira

              it goes in COMPONENTS.xml ... not pages.xml.


              you put hte exception's in pages.xml not events.

              • 4. Re: Seam login issue
                bashan

                Sorry, of course I was putting these lines in components.xml, I just wrote pages.xml by mistake...


                So, should I write the 2 tags I am using and this one as well:


                <event type="org.jboss.seam.postAuthenticate">
                          <action execute="#{redirect.returnToCapturedView}"/>
                     </event>



                or should I use the whole 3 tags?

                • 5. Re: Seam login issue
                  viktor.vra.geus.dk

                  Did you solve the problem? I want to do exactly the same in my project.