-
1. Re: Redirect to an URI during authentication?
swd847 Jun 30, 2009 5:15 AM (in response to asavitsky)Have you tried something like:
<navigation from-action="#{identity.login}"> <rule if="#{currentUser.legacyUser and identity.loggedIn}"> <redirect view-id="/changePassword.xhtml"></redirect> </rule> <rule if="#{identity.loggedIn}"> <redirect view-id="/index.xhtml"></redirect> </rule> </navigation>
-
2. Re: Redirect to an URI during authentication?
asavitsky Jun 30, 2009 4:55 PM (in response to asavitsky)Thanks for the suggestion, but apparently, it doesn't work. I probably should've mentioned that I also have standard post-login redirection in place:
<event type="org.jboss.seam.security.notLoggedIn"><action execute="#{redirect.captureCurrentView}" /></event> <event type="org.jboss.seam.security.postAuthenticate"><action execute="#{redirect.returnToCapturedView}" /></event>
and it seem to conflict with the navigation rules in pages.xml, as no matter whether the outjected currentUser is legacy or not, I'm always being redirected to the view that was requested prior to login, and never to changePassword.xhtml.
I'll continue to tinker more with this, though, as it does show potential to solve my problem.
Thanks,
Alex
-
3. Re: Redirect to an URI during authentication?
swd847 Jun 30, 2009 9:55 PM (in response to asavitsky)Create your own redirect component with your special case logic inside. Just copy and paste from the seam one and then in returnToCapturedView check if they are a legacy user and redirect them appropriatly.
-
4. Re: Redirect to an URI during authentication?
asavitsky Jul 2, 2009 4:31 PM (in response to asavitsky)Thanks, this actually worked pretty well, I didn't even have to copy the whole component - subclassing and overriding was enough:
@Name("org.jboss.seam.faces.redirect") @BypassInterceptors @Scope(ScopeType.CONVERSATION) @Install(classDependencies = "javax.faces.context.FacesContext", precedence = Install.FRAMEWORK) @PerNestedConversation public class MigrationRedirect extends Redirect { @Override public boolean returnToCapturedView() { User currentUser = (User) Contexts .lookupInStatefulContexts("currentUser"); if (currentUser != null && currentUser.isLegacyUser()) { FacesManager.instance().redirect("/pages/changePassword.xhtml"); return true; } return super.returnToCapturedView(); } }
Too bad the @In wouldn't work, because of @BypassInterceptors - but I decided to leave it be, as it's probably there for a reason.
Just thought I'd share it back with the community.
Again, my thanks,
Alex
-
5. Re: Redirect to an URI during authentication?
mangelo123 Jul 6, 2009 9:05 PM (in response to asavitsky)I can't think you guys enough! I have been battling this issue for weeks!!!
THANKS A MILLION! WORKS PERFECTLY!!