Fetch Current user in AEM Publish On PageLoad in AEM 6.5.9 | Community
Skip to main content
October 19, 2022
Solved

Fetch Current user in AEM Publish On PageLoad in AEM 6.5.9

  • October 19, 2022
  • 3 replies
  • 1107 views

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.
Best answer by Lokesh_Vajrala

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

3 replies

Lokesh_Vajrala
Community Advisor
Community Advisor
October 19, 2022

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? 

 

October 20, 2022

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 ?

Lokesh_Vajrala
Community Advisor
Lokesh_VajralaCommunity AdvisorAccepted solution
Community Advisor
October 20, 2022

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
October 20, 2022

@kautuk_sahni Need your inputs here please. Thanks

arunpatidar
Community Advisor
Community Advisor
October 20, 2022

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

The default or anonymous user is 'anonymous'

Arun Patidar