Forum Discussion

jpierlot's avatar
7 years ago

Auto redirect to signin page

Hi guys,

We are building a private Community. We want to redirect users on a custom page. In the page initializer of the Studio, I added the following code: 

<#if page.name == 'CommunityPage' >
<#if user.anonymous>
<# assign redirect_url = '/t5/custom/page/page-id/welcome?locale=en' />

  </#if>

</#if>

But all unregistered users are always redirected to the following page: https://xxxxx.com/t5/user/userloginpage?redirectreason=notregistered&dest_url=XXXX. 

Would anybody know how can I avoid this redirection so that the code in the Page initializer goes through?

Thanks in advance,

Julien. 

2 Replies

  • jpierlot

    Try this one

    <#if page.name == 'CommunityPage' >
    <#if user.anonymous>

    ${http.response.setRedirectUrl( "/t5/custom/page/page-id/welcome?locale=en")}
    </#if>

    </#if>

  • jpierlot

    Maybe it's simply what VikasB said and you are not dong the http.response.setRedirectUrl() or something else is wrong, it's hard to tell without seeing the entire page init code.

    Usually there is no automatic redirect from CommunityPage to LoginPage, so that has to come from somewhere, e.g. maybe your CommunityPage has some kind of Role (or something custom?) set that makes it "private" and requires users to login, e.g. some other logic would trigger that redirect to the LoginPage.

    Therefore the question: what comes before the code you posted above in the page init script?