7 Replies Latest reply on Feb 18, 2009 11:09 PM by swd847

    prevent the login page after logged in

      Hi every one

      I am using sema 2.1.1.GA.
      In my application the login page is the first page. After successfully logged in any user they can reach the home page of my application.
      Here my problem is after successfully logged in, any one click the browser back button they can reach the login page again. If they try to login again it will redirect to home page with you are already logged in .please logout first and login again like that.
      Instead this one, at the time of clicking the the browser back button I need to display this alert message on my home page.


      Is there any help …

        • 1. Re: prevent the login page after logged in
          swd847

          Vote for JBSEAM-3507.


          For now though you can do this:



          <page action="#{&quot;&quot;.toString()}" 
                    view-id="/login.xhtml">
                    <navigation from-action="#{&quot;&quot;.toString()}">
                         <rule if="#{identity.loggedIn}">
                              <redirect view-id="/myOtherPage.xhtml" />
                         </rule>
                    </navigation>
          </page>


          • 2. Re: prevent the login page after logged in
            after put this code in my pages.xml , i have same problem.
            if i put the following code into my login.page.xml it will fix the issue Partially.
            `
            <action execute='#{"".toString()}' />
                 
                 <navigation from-action='#{"".toString()}'>
                      <rule if="#{identity.loggedIn}">
                           <redirect view-id="/home.xhtml">
                           <!--message>You are already logged in!</message-->
                           </redirect>
                      </rule>
                 </navigation>     
            `

            after successfully logged in if try "http://localhost:8008/myproject/login.seam" url in browser addess bar , it will redirect me to home page.
            otherwise if i use the browser back button after sucessfully loggedin , it won't redirect me to home page.

            any help .

            by
            thiagu.m
            • 3. Re: prevent the login page after logged in
              swd847

              The browesr is caching the page, try something like this in pages.xml:



              <page expires="0" view-id="/login.xhtml">
                        <header name="Cache-Control" value="max-age=0" />
              </page>


              • 4. Re: prevent the login page after logged in
                i cant clear the browser cache after put he above code into my pages.xml file .
                this is what i am try in my project to reproduct this issue.
                first i create a new project by using seam 2.1.1.GA seam gen.
                then i edit the index.html from view folder and set URL="login.seam".
                then i add the following navigation roule in my login.page.xml file

                     <action execute='#{"".toString()}' />     
                     <navigation from-action='#{"".toString()}'>
                          <rule if="#{identity.loggedIn}">
                               <redirect view-id="/home.xhtml">
                               <message>You are already logged in!</message>
                               </redirect>
                          </rule>
                     </navigation>

                then i add the following code in my pages.xml file
                     
                <page expires="0" view-id="/login.xhtml">
                     <header name="Cache-Control" value="max-age=0" />
                </page>

                then i build build the project and startup my server.
                then i try to access my project it will load the login.seam as a first page.
                then i logged in by using admin user name.
                then i hit the browser back button , it will redirect me to login.seam page.
                i need to redirect home page with face message.

                any help
                by
                thiagu.m
                • 5. Re: prevent the login page after logged in
                  swd847

                  There are lots of other headers and html meta tags that control caching, have a google and read up on them (its really not my area, I think you probably want the no-cache header rather that max-age=0, sorry). To verify that this is a caching issue clear the browser cache manually before hitting the back button and see what happens.


                  Stuart

                  • 6. Re: prevent the login page after logged in

                    thank you for reply.
                    now it is working correctly.this is what i did .
                    first i put those navigation rules.
                    then i build the project and startup the server.
                    after successfully logged in, i clear the browser cache , then i hit the browser back button it wont allow me to reach login page again. it will shows the home page with alert message.
                    now i am search how to clear the browser cache.
                    if any one knows help me ..


                    by
                    thiagu.m

                    • 7. Re: prevent the login page after logged in
                      swd847

                      You cannot clear the browser cache, what you have to do is instruct the browser not to cache the page, have a look here for some more info. I think


                      <page  view-id="/login.xhtml">
                                <header name="Cache-Control" value="no-cache" />
                      </page>
                      



                      is probably what you are after.