Expand my Community achievements bar.

Join expert-led, customer-led sessions on Adobe Experience Manager Assets on August 20th at our Skill Exchange.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Signout function

Avatar

Level 2

Hi all,

I've customised a login function for my website. The signout function will set user to be anonymous and reload the page. But when I logout from a Closed User Group enabled page, it redirects to 404 page not found because anonymous does not have the right to see the CUG page. How can I redirect the page to homepage after sign out? I have tried window.location.replace('/') and window.location.href('/content/mywebsite/home.html')but this will redirect me to 403 Forbidden page.

The only function that can work is window.location="<URL>" but I do not want to hardcode the website URL. What else can I do?

Below are the signout js function:

function signout() { sendRequest('<%=request.getContextPath()%>', 'anonymous', 'null'); window.location.reload(); }
function sendRequest(contextPath, user, pass) { var xmlhttp = getXmlHttp(); if (!xmlhttp) { return; } if (xmlhttp.readyState < 4) { xmlhttp.abort(); } xmlhttp.open('GET', contextPath + "?sling:authRequestLogin=1", false, user, pass); xmlhttp.send(''); return xmlhttp.status != 403; }
1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Please test the log out functionlity in your publish instance. If it works there, then you are good. End of the day, it is the publish instance that is going to face the users.

Reasons:

1) Author instance's security configurations are such a way that anonymous users don't have access even to /content

2) But this is not the case in your publish instance. By default anonymous users have read access to all nodes under /etc and /content

This set up is to protect your author instance from access to anyone apart form the admin and authors who have valid credentials

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

Please test the log out functionlity in your publish instance. If it works there, then you are good. End of the day, it is the publish instance that is going to face the users.

Reasons:

1) Author instance's security configurations are such a way that anonymous users don't have access even to /content

2) But this is not the case in your publish instance. By default anonymous users have read access to all nodes under /etc and /content

This set up is to protect your author instance from access to anyone apart form the admin and authors who have valid credentials

Avatar

Level 10

Since window.location working. To construct the url use window.location object itself to get hostname , port etcc...