Forum Discussion

hayata's avatar
4 years ago

Return to same page after sign out

Is there a setting that returns the user back to the same page after signing out.  The default behavior takes the user back to the home page.

  • SuzieH's avatar
    SuzieH
    Khoros Alumni (Retired)

    Hi hayata.

    The attachment inWhat happens when a user signs out of the community? says that you can define a URL to direct to at sign-off when SSO is enabled. That said, the URL must be accessible to anonymous users otherwise the user will be taken to the Community home page, as you're experiencing. 

    The flow for non-SSO communities is similar, but slightly different. Upon sign-off, the user is taken back to the page they were currently on (if that page is accessible to anonymous users); otherwise, they are taken to the Community home page. There is no place in Admin to change the redirect upon sign-off. You might be able to override the Sign out link component to add logic to take the user to a different location. (You'd name the component users.action.logout@override). Regardless, wherever you send the user, be sure to check that the page you're sending them to is accessible by anonymous users. 

    To set the URL in a customer component, you'd use the webUi.getUserLogoutPageUrl FreeMarker method. Something like this - although there is likely more business logic you'll want to add for your use case:

    
    <#if user.anonymous == false>
     <#assign signoff_url = webUi.getUserLogoutPageUrl("https://www.acme.com/path/to/where/they/want/user/to/go") />
     <a class="lia-link-navigation logout-link lia-link-ticket-post-action lia-component-users-action-logout" rel="nofollow" href="${signoff_url}">${text.format("general.logout")}</a>
    </#if>
    

    Also, the hostname of the URL will be validated against a configuration that contains valid host names. Khoros Support should be able to verify whether the hostname is already in your community config or help you add it, if needed.