Forum Discussion

wearesocialit's avatar
7 years ago

Redirect user registered with SSO but with profile incomplete

Hi all,

 

I have a community with SSO, and I need to redirect users that does not have a complete profile to the complete profile page.

I've tried the following code, in Common.init, which does not work:

 

<#if page.name == "UserProfileRedirect">
<#assign redirect_url = "/" />
<#attempt> <#if user.registered && user.registration.complete == false>
<#assign redirect_url = webuisupport.urls.page.name.UserSsoRegistrationPage.build() />
</#else>
<#assign redirect_url = webuisupport.urls.page.name.ViewProfilePage.path("user-id",user.id?string).build() />
</#if> <#recover> </#attempt> ${http.response.setRedirectUrl(redirect_url)}
</#if>

Almost the same code works perfectly to render a button:

 

 

<#if user.registration.complete == false >
  <a href="${webuisupport.urls.page.name.UserSsoRegistrationPage.build()}">COMPLETE PROFILE</a>
<#else>
  <a href="#">PROFILE OK</a>
</#if>

Thanks in advance

  • VikasB's avatar
    VikasB
    7 years ago

    wearesocialit

    You are using the wrong syntax for if else.  As <#else> is in existing directive, but the tag is malformed. So you need to use <#else> instead of </#else> Try this one

     

    <#if page.name == "UserProfileRedirect">
    <#assign redirect_url = "/" />
    <#attempt>
        <#if user.registered && user.registration.complete == false>
          <#assign redirect_url = webuisupport.urls.page.name.UserSsoRegistrationPage.build() />
        <#else>
          <#assign redirect_url = webuisupport.urls.page.name.ViewProfilePage.path("user-id",user.id?string).build() />
        </#if>
      <#recover>
      </#attempt>
    
      ${http.response.setRedirectUrl(redirect_url)}
    </#if>

     

3 Replies

  • No, I simply get redirected to the wrong page i.e.: webuisupport.urls.page.name.ViewProfilePage.path("user-id",user.id?string).build() 

  • VikasB's avatar
    VikasB
    Boss
    7 years ago

    wearesocialit

    You are using the wrong syntax for if else.  As <#else> is in existing directive, but the tag is malformed. So you need to use <#else> instead of </#else> Try this one

     

    <#if page.name == "UserProfileRedirect">
    <#assign redirect_url = "/" />
    <#attempt>
        <#if user.registered && user.registration.complete == false>
          <#assign redirect_url = webuisupport.urls.page.name.UserSsoRegistrationPage.build() />
        <#else>
          <#assign redirect_url = webuisupport.urls.page.name.ViewProfilePage.path("user-id",user.id?string).build() />
        </#if>
      <#recover>
      </#attempt>
    
      ${http.response.setRedirectUrl(redirect_url)}
    </#if>