Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
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...

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----