I have an app using jsf2, jboss 6.1 and seam 3. I want to do something like this:
if the user tries to access the app and is not authenticated, he should be directed to the login page. If the user, is already logged in even if he types the login url he should be directed to a home page, and not login again. So I put this on faces-config.xml
<navigation-rule>
<navigation-rule>
<from-view-id>/login.xhtml</from-view-id>
<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>
<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-rule>
But the first rule doesnt work. If the user types the url with the login.xhtml he stays on the page. I need him to be redirected. How can I do that?
Thanks
Kelly