I have an sightly component(.html) from where I am calling a method of my handler. In my handler I want to check userId of the loggedIn user and based on the loggedIn user I want to make that method of handler return values. How can I get the user Id of loggedIn user who is calling this handler. My html is as :
<div data-sly-unwrap data-sly-use.handler="${'com.my.wcm.sightly.handlers.MyHandler'}"> <a href="${handler.linkforloggedinUser}">${handler.linkTitle}</a><br/> </p> </div>
My Handler has simple activate method as its extending WCMUse class. Please suggest any way to get the user in my handler.
Solved! Go to Solution.
You can get the userid from the resource resolver object- https://docs.adobe.com/content/docs/en/aem/6-0/develop/ref/javadoc/com/adobe/cq/sightly/WCMUse.html#...
ResourceResolver resourceResolver = getResourceResolver(); Session session = resourceResolver.adaptTo(Session.class); String userId = session.getUserID();'
You can get the userid from the resource resolver object- https://docs.adobe.com/content/docs/en/aem/6-0/develop/ref/javadoc/com/adobe/cq/sightly/WCMUse.html#...
ResourceResolver resourceResolver = getResourceResolver(); Session session = resourceResolver.adaptTo(Session.class); String userId = session.getUserID();'
kunal23 wrote...
You can get the userid from the resource resolver object- https://docs.adobe.com/content/docs/en/aem/6-0/develop/ref/javadoc/com/adobe/cq/sightly/WCMUse.html#...
ResourceResolver resourceResolver = getResourceResolver();
Session session = resourceResolver.adaptTo(Session.class);
String userId = session.getUserID();'
Hey Thanks Kunal, I had done it so many times but got confused this time. Thanks for helping me out.
Views
Replies
Total Likes
Views
Likes
Replies