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; }
Solved! Go to Solution.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Since window.location working. To construct the url use window.location object itself to get hostname , port etcc...
Views
Replies
Total Likes