How to redirect page request by user loggedin
I am developing a site with Seam 3 and JBoss 7. I'm using Seam security and JSF. The front page of the site has the login controls. When the user enters his credentials he is redirected to his user page "/MySC".
But if the logged-in user just types the domain root "/" he gets to the front page. What I want is that when the user is logged-in, he should not be able to access the front page again. If he requests to go to the front page or enter the d开发者_C百科omain root in the location bar, I want him to be redirected to "/MySC". How can I do that?
You can use SEAM navigation rule which is quite powerful.. You declare it in page.xml... You can declare conditional navigation rule there..
<page view id="/view.xhtml">
<navigation from-action="#{user.login}">
<rule if-outcome="successfull"><redirect view-id="/MySC.xhtml"/>
<message severity="Info">
Your login is successfull!.
</message>
</navigation>
</page>
I recommend a small redesign the page structure: Make the front page /start
the page that an authenticated user is allowed to see, and redirect to /login
if the user is not authenticated yet.
This design is not only cleaner in terms of separation of concerns (allows you to bundle the authentication logic in a distinct folder), it also solves the problem of mixing context root and authentication page.
精彩评论