Fetch Current user in AEM Publish On PageLoad in AEM 6.5.9 | Community
Skip to main content
New Participant
Oct 19, 2022 5:19 PM UTC
Solved

Fetch Current user in AEM Publish On PageLoad in AEM 6.5.9

Hi , I am using '/libs/granite/security/currentuser.json' to fetch current user in js. I see it is returning user as expected in Author instance where as In Publish it always returns 'anonymous'. 
I tried logging into Publish AEM but still the user state is not persisting. Is there a way we can achieve this ?

Version of AEM : 6.5
ServicePack : AEM 6.5 Service Pack 9 (6.5.9.0) 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Lokesh_Vajrala
Lokesh_VajralaAccepted solution
New Participant
Oct 20, 2022 3:11 AM UTC

You can hit the login end-point - /libs/granite/core/content/login.html directly, which will give you the login screen and you should be able to login to Publish instance. 

 

http://localhost:4503/libs/granite/core/content/login.html

5 replies

arunpatidar
New Participant
Oct 20, 2022 8:14 AM UTC

if you are not logged in AEM then you will not get user details.

The default or anonymous user is 'anonymous'

Translate
Arun Patidar
New Participant
Oct 20, 2022 3:04 AM UTC

@kautuk_sahni Need your inputs here please. Thanks

Translate
Lokesh_Vajrala
New Participant
Oct 19, 2022 8:42 PM UTC

Hi @madhurimaddala26 , is it working when you hit the path - http://localhost:4503/libs/granite/security/currentuser.json directly in a browser window instead after logging in? 

 

Translate
New Participant
Oct 20, 2022 3:03 AM UTC

Hi ,Thanks for replying.
The issue I see is Publish instance is not allowing us to login I tried with Weretail and I can see the issue there as well. 
http://localhost:4503/libs/granite/security/currentuser.json is always returning anonymous ID. The loggedin state of user is not persisting.

{"type":"user","authorizableId_xss":"anonymous","authorizableId":"anonymous","name_xss":"anonymous","name":"anonymous","home":"/home/users/8/8QmmwYU5F6MOHNiF0XEI","isImpersonated":false}

Is there any other way we can get user name on pageload ?

Translate
Lokesh_Vajrala
Lokesh_VajralaAccepted solution
New Participant
Oct 20, 2022 3:11 AM UTC

You can hit the login end-point - /libs/granite/core/content/login.html directly, which will give you the login screen and you should be able to login to Publish instance. 

 

http://localhost:4503/libs/granite/core/content/login.html
Translate