CurrentUser.json always returning Anonymous in Publish instance and works well in author | Community
Skip to main content
October 20, 2022
Solved

CurrentUser.json always returning Anonymous in Publish instance and works well in author

  • October 20, 2022
  • 3 replies
  • 1468 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) 

 

 

USECase : I have to show Login text when user is not loggedin and LOGOUT text with his name  when user is loggedin.

Thanks

@kautuk_sahni Your inputs please. 

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 joerghoh

In publish, when you are a not authenticated you are using the "anonymous" user. When you want to work with user identities and different permissions, I would recommend to check the documentation on "Closed User Groups" (CUG).

 

https://experienceleague.adobe.com/docs/experience-manager-learn/assets/advanced/closed-user-groups.html?lang=en

3 replies

manjunathdj
Level 1
October 20, 2022
arunpatidar
Community Advisor
Community Advisor
October 20, 2022

you should have AEM session and read access to /libs/granite/security/currentuser.json

Arun Patidar
joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 21, 2022

In publish, when you are a not authenticated you are using the "anonymous" user. When you want to work with user identities and different permissions, I would recommend to check the documentation on "Closed User Groups" (CUG).

 

https://experienceleague.adobe.com/docs/experience-manager-learn/assets/advanced/closed-user-groups.html?lang=en