1 Reply Latest reply on Jul 18, 2012 6:24 PM by zeeman

    redirect user if already logged in

    kgoedert

      Hi,

       

      I am using seam 3 security and I want to bypass the login page if the user is already logged in. I tried to put this in faces-config.xml but it did not work

       

      {code}

      <navigation-rule>

                          <from-view-id>*</from-view-id>

                          <navigation-case>

                                    <from-action>#{identity.login}</from-action>

                                    <if>#{identity.loggedIn}</if>

                                    <to-view-id>/user/search.xhtml</to-view-id>

                                    <redirect>

                                              <view-param>

                                                        <name>cid</name>

                                                        <value>#{userBean.conversation.id}</value>

                                              </view-param>

                                    </redirect>

                          </navigation-case>

                          <navigation-case>

                                    <from-action>#{identity.login}</from-action>

                                    <from-outcome>failed</from-outcome>

                                    <to-view-id>/denied.xhtml</to-view-id>

                          </navigation-case>

                          <navigation-case>

                                    <from-outcome>login</from-outcome>

                                    <to-view-id>/login.xhtml</to-view-id>

                                    <redirect />

                          </navigation-case>

                          <navigation-case>

                                    <if>#{identity.loggedIn}</if>

                                    <to-view-id>/user/search.xhtml</to-view-id>

                                    <redirect>

                                              <view-param>

                                                        <name>cid</name>

                                                        <value>#{userBean.conversation.id}</value>

                                              </view-param>

                                    </redirect>

                          </navigation-case>

                </navigation-rule>

      {code}

       

      What I want is: if the user is not logged in, he should be redirected to the login page, if he is already logged in, he should be redirected to another page, bypassing the login.

       

      Thanks for any help

       

      Kelly

        • 1. Re: redirect user if already logged in
          zeeman

          There are different ways of doing it. You can observe AlreadyLoggedInEvent, then redirect to page you want. Anotherway, look at ViewsConfig in seams security documentation, it lets you set login, access denied, and home pages.