Reputation: 2858
After the user is successfully logged in i would normally put some of his info on a session object. Then I would use a Filter applied to all pages to check if any user is logged in or not.
How can I achieve something like this with JSF 2.0?
Upvotes: 0
Views: 348
Reputation: 1812
you can put all of login required pages to subfolders and leave login.xhtml at root directory.
you may keep your user in session scope with a class called identity you can then add these declarations to your pages.xml.
so you will not need to check everywhere if user logged in.
<page view-id="*">
<navigation>
<rule if-outcome="home">
<redirect view-id="/base/home.xhtml"/>
</rule>
</navigation>
<navigation from-action="#{identity.logout}">
<rule if="#{not identity.loggedIn}">
<redirect view-id="/login.xhtml"/>
</rule>
</navigation>
</page>
<page view-id="/modul*" login-required="true"></page>
<page view-id="/popup*" login-required="true"></page>
Upvotes: 1