3 Replies Latest reply on Jan 20, 2008 6:30 PM by Jacob Orshalick

    Conditional redirect after authenticator action

    m k Newbie

      Hi,

      i want to redirect to different pages depending on some logic in my authenticator method.

      The authenticator has boolean return value, so i can not generate a different outcome (String) in the mehtod.

      Any ideas appreciated.

      Best regards

      mk

        • 1. Re: Conditional redirect after authenticator action
          Nicklas Karlsson Master

          How about setting "something somwhere" in the authenticator method and then placing an observer on the successful login event and redirect there?

          (note, not tried, just brainstorming)

          • 2. Re: Conditional redirect after authenticator action
            Nicklas Karlsson Master

            ok, the "something somewhere" can probably be used in a test for pages.xml too for redirection.

            • 3. Re: Conditional redirect after authenticator action
              Jacob Orshalick Apprentice

              Yes, the approach nickarls is describing works quite well.

              I implemented something similar by wrapping the Seam Identity component and included the authenticate method in the wrapper. Your wrapping login() method can then delegate the login call and then return any navigation String you want based on what occurred in the authenticate method.

              For example,

              @Name("customIdentity")
              public class CustomIdentity {
               private String authenticateResult;
               ... ...
               public String login() {
               // delegate login call which in turn calls authenticate method
               Identity.instance().login();
              
               return authenticateResult;
               }
               ... ...
               public boolean authenticate() {
               // logic that authenticates and sets authenticateResult
               }
               ... ...
              }


              Simply invoke the wrapping login method from your login page. I apologize if there are any errors in the code as I'm just coding directly in the post :)