Hi Team ,
I am able to get the current user in JS by adding the dependency cq.widgets .But, it contains many JS files .So,can someone suggest what are the exact JS files required.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi
Please have a look at this Stackoverflow question :
Link:- http://stackoverflow.com/questions/33132102/aem-get-current-userid
//
if you want to get user in java, you can user Resource Resolver API.
Session session = resourceResolver.adaptTo(Session.class); session.getUserID();
if you want to get user on Front end, you could use Profile Data Manager API
<script> CQ_Analytics.ProfileDataMgr.data </script>
Link:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage... (Almost Same Question)
//
Session session = resourceResolver.adaptTo(Session.class); UserManager userManager = resourceResolver.adaptTo(UserManager.class); /* to get the current user */ Authorizable auth = userManager.getAuthorizable(session.getUserID()); /* to get the property of the authorizable. Use relative path */ Value[] names = auth.getProperty("./profile/familyName"); /* to get the groups it is member of */ Iterator<Group> groups = auth.memberOf();
To list all the users or groups, you can use findAuthorizables() method available in the UserManger.
You can also obtain the User info in JS using CQ.User.getCurrentUser() which would return an instance of the current User, with which you can access the user's properties.
Link:- https://helpx.adobe.com/experience-manager/using/using-ajax-requests-display-cq.html (Community article)
//Using AJAX requests to display Adobe CQ users in a grid control
I hope this would help you.
Thanks and Rerards
Kautuk Sahni
Views
Replies
Total Likes
If you want to to determine this, look at the JS libs that are loaded when the browser invokes script that contains s this logic. Also, it is not recommended to attempt to remove any libs from an AEM component.
Views
Replies
Total Likes
If you want to get the user id on publish in javascript code then you can make a simple HTTP GET request to user properties URL. Thats what the CQ library code uses to get the current user id.
//Sample code which uses jQuery API var data = $.get('/libs/cq/security/userinfo.json') var userId = data.responseJSON.userID;
Views
Replies
Total Likes
But you will have to make sure that this URL is not blocked by the dispatcher and is passed through. If you think that it should be blocked for security reasons then I would suggest that you write a simple servlet in Java code which will return only the current user id and not other information about the user. And then you can make an HTTP GET request to that servlet to get the current user id.
Views
Replies
Total Likes
Hi
Please have a look at this Stackoverflow question :
Link:- http://stackoverflow.com/questions/33132102/aem-get-current-userid
//
if you want to get user in java, you can user Resource Resolver API.
Session session = resourceResolver.adaptTo(Session.class); session.getUserID();
if you want to get user on Front end, you could use Profile Data Manager API
<script> CQ_Analytics.ProfileDataMgr.data </script>
Link:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage... (Almost Same Question)
//
Session session = resourceResolver.adaptTo(Session.class); UserManager userManager = resourceResolver.adaptTo(UserManager.class); /* to get the current user */ Authorizable auth = userManager.getAuthorizable(session.getUserID()); /* to get the property of the authorizable. Use relative path */ Value[] names = auth.getProperty("./profile/familyName"); /* to get the groups it is member of */ Iterator<Group> groups = auth.memberOf();
To list all the users or groups, you can use findAuthorizables() method available in the UserManger.
You can also obtain the User info in JS using CQ.User.getCurrentUser() which would return an instance of the current User, with which you can access the user's properties.
Link:- https://helpx.adobe.com/experience-manager/using/using-ajax-requests-display-cq.html (Community article)
//Using AJAX requests to display Adobe CQ users in a grid control
I hope this would help you.
Thanks and Rerards
Kautuk Sahni
Views
Replies
Total Likes