22 Replies Latest reply: Sep 5, 2013 3:11 AM by Yashita Goyal RSS

    Redirect after registration

    kevin.vanderbijl

      Hi Community,

       

      I'm new to Jive but sturggling with a question about redirects. Is it possible to redirect a new user the last page visited when they have completed the registration steps. They are currently redirected to the home page.

       

      I hope this can be done?

       

      Yours Sincerely

      Kevin

        • Re: Redirect after registration
          Ryan Rutan

          Its been my experience that the login/register actions tend to use the jive.referer session property, such that when complete ... the user can be redirected to the desired post auth action.

           

          If it were me, I would try the following:

          • Create a new Action (for example: /my-registration.jspa)
            • In this action, simply do a session.put(JiveConstants.REFERER_KEY,"yourURL");
            • then redirect the user to the Registration Wizard start URL ... (....jspa)
          • When they are done, the wizard should check the session, remove the key (pop), and redirect the user to that page if found.

           

          Like I said, I haven't coded this exact use-case, but this is how I would do it to try and keep from overriding the Wizard completely.

           

          Hope this helps,

          RR

            • Re: Redirect after registration
              kevin.vanderbijl

              Hi Ryan,

               

              I will try this today and hope that it wil work. Thanks for your fast reply and I will give you feedback afterwards.

               

              Thanks

              Kevin

              • Re: Redirect after registration
                kevin.vanderbijl

                I'm finding it very difficult to get this working, I'm fairly new to jive and i'm wondering how I should do this. I have some questions regarding;

                 

                How can i create a new action?

                Where do i have to put this file?

                Where can i find my registration start url, because this needs to be dynamic?

                 

                Thanks for helping me out.

                 

                Kevin

                • Re: Redirect after registration
                  Roguen Keller

                  Hi Ryan Rutan

                  I ran into this same need and gave this a try.  It did not work for me though, and so I thought I would come back for guidance.

                   

                  As you mentioned, I'm working with the following struts action:

                  <action name="create-account" class="com.jivesoftware.xxx.community.action.CreateNewUserAccountAction"

                              method="input">

                              <interceptor-ref name="defaultStack"/>

                              <interceptor-ref name="token">

                                  <param name="excludeMethods">cancel,input</param>

                              </interceptor-ref>

                              <result name="unavailable">/template/global/registration-unavailable.ftl</result>

                              <result name="cancel" type="redirect">index.jspa</result>

                              <result name="not-authorized" type="redirect">login.jspa</result>

                              <result name="input">/plugins/dynamic-theme/resources/templates/global/create-account.ftl</result>

                              <result name="success" type="redirect">${communityURL}/${joinedCommunityDisplayName}</result>

                              <result name="success-wizard" type="redirect">user-wizard-profile!input.jspa</result>

                              <result name="success-pending" type="redirect">${communityURL}/${joinedCommunityDisplayName}?pending=1</result>

                          </action>

                  As you can see I have 3 different possible paths, but in the end I want all 3 of them to go back to this referring page (the space I just joined)

                   

                  The last few lines in the execute method of my CreateNewUserAccountAction look like this:

                  session.put(JiveConstants.REFERER_KEY, communityURL + "/" + getJoinedCommunityDisplayName());

                  return isUserWizardEnabled() ? SUCCESS_WIZARD : SUCCESS;

                  Which again, would match what you're seeing in the struts action

                   

                  I walked through this and saw that it was setting the session variable.  I have the following values in session:

                  {old.jive.referer=/community/sapce/subspace, jive.presence=com.jivesoftware.community.presence.impl.PresenceImpl@6203cc7, com.jivesoftware.api.core.aaa.CoreApiCsrfTokenGenerator=11E9D42E1CE8507341F2C7866A6BC0DA:efe9d087ebe1bb9c3e0f8cf32f52892abef42ddd83dbdc41d98d6b4c808fbd8f, sitemesh-decorator=default, __sitemesh__robot=false, iso_community_id=2005, jive.referer=space/subspace, _jive.session.sourceIP=0:0:0:0:0:0:0:1%0, _jive.session.resource=/login.jspa}

                  But in the end I have the same landing page as I did before.

                  Are there any recommendations you can make?  I would appreciate it.

                   

                  thanks

                    • Re: Redirect after registration
                      Roguen Keller

                      I found that the current WizardCompleteAction which this process leads up to isn't actually doing anything with this session value.  In my own plugin I created a new Action to replace this one and overrode the struts action for user-wizard-complete.

                       

                      The code added to my action looked like this:

                          String joinedCommunity = (String)session.get("JiveConstants.REFERER_KEY");
                          if (joinedCommunity!=null && !joinedCommunity.equals("")) {
                              newLandingURL = joinedCommunity;
                              session.remove("mostRecentlyJoinedCommunity");
                          }
                          // only go to info page if this user has received any invitations to join
                          if (null != invitations && !invitations.isEmpty()) {
                              return INFO;
                          } else {
                              if (newLandingURL != null && !newLandingURL.equals("")) {
                                  return SUCCESS;
                              } else {
                                  return REDIRECT;
                              }
                          }

                      As well as adding getters and setters for the vars I would use in struts.

                      My new struts action looked like this in the plugin:

                           <action name="user-wizard-complete"

                                  class="com.jivesoftware.pluginname.community.action.wizard.WizardCompleteAction">

                                  <param name="adminWizard">false</param>

                                  <result name="not-authorized" type="redirect">index.jspa</result>

                                  <result name="redirect" type="redirect">index.jspa</result>

                                  <result name="success" type="redirect">${newLandingURL}</result>

                              </action>

                       

                      This took me to the place I wanted to go.  I should point out though that it does NOT work when you use it in conjunction with registration moderation.  You would need to hold the value in something like a cookie until the user came back after being accepted.

                  • Re: Redirect after registration
                    Iurii Luzan

                    Does anyone have solution for jive 6?

                      • Re: Re: Redirect after registration
                        dudley.nelson

                        I've just implemented this in Jive 6, in a much simpler manner than described above.

                         

                        I've done it with a single struts change. I've implemented an override of the create-account action and instead of pointing the success at the soy page, I've instead issued a redirect to ${jive.referrer}. No other changes needed!

                         

                        The entire snippet for your enjoyment follows:

                         

                        <action name="create-account" class="com.jivesoftware.community.action.CreateNewUserAccountAction">
                            <interceptor-ref name="defaultStack"/>
                            <result name="unauthorized" type="redirect">login.jspa</result>
                            <result name="unavailable" type="soy">jive.user.registration.unavailablePage</result>
                            <result name="success" type="redirect">${jive.referer}</result>
                        </action>
                        
                          • Re: Re: Redirect after registration
                            Iurii Luzan

                            Hm, that solution does not work, coz it forcibly redirect /create-account.jspa to referer with or without registration process.

                              • Re: Redirect after registration
                                dudley.nelson

                                I don't follow you - it'll only do the redirect if the registration process succeeds?

                                 

                                And it's working here just fine - it's not gone through formal testing yet, but I've been testing it and yet to have any problems. What's the use case you've found where it fails?

                                  • Re: Redirect after registration
                                    Iurii Luzan

                                    On page /login.jspa you can see registration link. With your action any click on that link will redirect you to the /login.jspa

                                      • Re: Redirect after registration
                                        dudley.nelson

                                        That's not what it's doing for me - but it's not behaving as I would like.

                                         

                                        What it is doing for me is:

                                        • Visit a content page
                                        • Visit the dedicated login page ( /login.jspa )
                                        • Visit the dedicated registration page (/create-account.jspa)
                                        • Successful registration takes you to get-started ( /get-started )

                                         

                                        It won't go back to login.jspa, because LoginAction.java has @SetReferrer(false) at the top of the action, but this particular path to registration isn't taking you back to the page the user was on post registration :<

                                         

                                        I'm not sure why either - I'll keep poking.

                                  • Re: Redirect after registration
                                    Yashita Goyal

                                    Hi Nelson,

                                     

                                    I am having the similar requirement.

                                     

                                    Description:- After successful registration user should redirect to respective Edit-profile page.

                                     

                                    I have figured out the final user redirection to "/" page is from user_registration_source.js file.

                                    In my plugin am trying to replace "/" --> "/edit-profile!input.jspa?targetUser=" + <userid>

                                    But unable to get the userid at this point of time.

                                     

                                     

                                     

                                    It will be very grateful if you can help me out on urgent basis.

                                     

                                    Thanks & Regards,

                                    Yashita Goyal

                                • Re: Redirect after registration
                                  Rohit Wadke

                                  Hi Ryan Rutan

                                   

                                  We are converting our jive4 ldap plugin code to jive6 compatible.

                                   

                                  What are the alternative variables (underlined) for below code ?

                                   

                                  userTemplate = (UserTemplate) session.get(ValidateAction.SESSION_VALIDATION_KEY);

                                  this.termsInternal = JiveGlobals.getJiveBooleanProperty(RegistrationManager.PROPERTY_TERMS_IS_INTERNAL, StringUtils.isEmpty(termsUrl));

                                  session.containsKey(JiveRefererInterceptor.JIVE_REFERER_KEY)

                                   

                                   

                                  =============================================

                                  Struts.xml

                                  <package name="ldapsync-actions" extends="community-actions">

                                          <action name="create-account" class="com.jivesoftware.community.action.EclipsysCreateNewUserAccountAction" method="input">

                                              <result name="unavailable">/template/global/registration-unavailable.ftl</result>

                                              <result name="cancel" type="redirect">index.jspa</result>

                                              <result name="not-authorized" type="redirect">login.jspa</result>

                                              <result name="input">/plugins/ldapsync/resources/templates/global/create-account.ftl</result>

                                              <result name="success" type="redirect">index.jspa</result>

                                              <result name="success-wizard" type="redirect">user-wizard-profile!input.jspa</result>

                                              <result name="success-pending" type="redirect">account-pending.jspa</result>

                                          </action>       

                                      </package>

                                   

                                   

                                  As wizard is removed in Jive6, what the the alternative solution for user-widard-profile?

                                   

                                  Thank you,

                                  Rohit

                                    • Re: Redirect after registration
                                      Ryan Rutan

                                      Could you confirm the business intent of this plugin?  While you are correct that this has changed in Jive 6, I'm not heard of a plugin to date that does LDAP integration at the Create Account page.  Perhaps this feature isn't needed anymore?

                                        • Re: Redirect after registration
                                          Jaffrin Abdul Salam

                                          Hi  Ryan,

                                          The  question that posted above is from one of the developer that i work with. We are upgrading from jive 4 to jive6. We are trying to create users in ldap during the registration process. I know that in jive 6 , user creation through usertemplate is not supported. Our plugin create users in ldap. Since we upgraded to jive6, we are rewriting our plugin. Please let me know, what class should i extend to persist the user in ldap or can i do it in the action class?please advice.

                                           

                                          Thanks,

                                          Jaffrin

                                            • Re: Redirect after registration
                                              Ryan Rutan

                                              Personally, I would use a UserListener to do this level of integration; however, when it comes to extending specific/actions, etc... I do not have a solution to offer unfortunately =\  I do know that in Jive 6, the registration creation is done via Services, rather than  Struts, so the number of options in Struts to extend will be more limited than in previous Jive versions.  Hope that helps.

                                        • Re: Redirect after registration
                                          kathy nguyen

                                          In JIVE 6.0.3, what I did was customize the /resources/scripts/apps/userregistration/views/user_registration_form_view.js and added a line to force the redirect. It'd be in the attemptLogin at about line 216. You could retrieve the value of the "referer" parameter in "view.options.successURL"

                                          Hope that helps.