0 Replies Latest reply on Mar 13, 2010 9:58 PM by jon

    Redirect to login page not working

    jon

      Hi,


      I have a login page which should be redirected to when loading the URL for my application. Here is pages.xml:




      <pages login-view-id="/login.seam" no-conversation-view-id="/login.seam">
      
           <page view-id="/secure/*" login-required="true">
                <restrict>#{s:hasRole('nrg2User')}</restrict>
           </page>
           
           <page view-id="/admin/*" login-required="true">
                <restrict>#{s:hasRole('nrg2Admin')}</restrict>
           </page>
           
           <page view-id="*">
               <navigation from-action="#{identity.logout}">
                    <redirect view-id="home" />
               </navigation>
          </page>
           
           <exception class="org.jboss.seam.security.NotLoggedInException">
              <redirect view-id="/index.html">
                  <message>You must be logged in to perform this action</message>
              </redirect>
          </exception>
          
          <exception class="org.jboss.seam.security.AuthorizationException">
              <end-conversation/>
              <redirect view-id="/index.html">
                  <message>You do not have the necessary security privileges to perform this action.</message>
              </redirect>
          </exception>
          
          <exception>
          <end-conversation/>
            <redirect view-id="/error.html">
                 <message severity="ERROR">Exception: #{org.jboss.seam.handledException.message}</message>
            </redirect>
         </exception>
          
      </pages>





      and the relevant part of components.xml:




      <security:identity authenticate-method="#{authenticator.authenticate}" />
         
         <event type="org.jboss.seam.security.notLoggedIn">
             <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
             <action execute="#{redirect.returnToCapturedView}"/>
         </event>
              <event type="org.jboss.seam.postAuthenticate">
               <action execute="#{redirect.returnToCapturedView}"/>
         </event>




      However the application tries to redirect to the home page, and throws an error because the username is null - this is because the user has not had the chance to enter it on the login page, where the username is assigned to the Seam identity instance.


      Any ideas?
      Thanks,
      Jon