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; }