Hi,
I want to show button on page if logged in user is admin or members of the administrators group in javascript.
I am able to get CQ.User.getCurrentUser() but not able to check if user is admin.
Solved! Go to Solution.
I guess there in no ootb feature, but you can write a simple servlet and make a ajax call. That would be easy.
Views
Replies
Total Likes
I guess there in no ootb feature, but you can write a simple servlet and make a ajax call. That would be easy.
Views
Replies
Total Likes
The following URI returns all the users who are member of 'administrators' group. You can check the existence current user Id in the JSON response returned by the URI-
http://localhost:4502/libs/granite/security/search/authorizables.json?query={%22scope%22:{%22groupNa...
Hi
As mentioned by Praveen, you can achieve the desirable by creating custom service or component.
For more reference please have a look at this forum post :- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi Kunal
I have tried the link specified by you with my test user, but i am not getting the desirable result.
Test user :- "Administrator","home":"/home/users/9/xxxxx"}],"total":2} (only ending of json response)
Admin User:- "Administrator","home":"/home/users/9/xxxxx","isImpersonated":false}],"total":2} (only ending of json response, rest all was same.)
Could you please help me in understanding it ?
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi Kautuk,
The JSON response lists the properties of the user who are member of administrators group. I get the following response back -
{"authorizables":[{"type":"user","authorizableId_xss":"replication-receiver","authorizableId":"replication-receiver","name_xss":"replication-receiver","name":"replication-receiver","home":"/home/users/system/replication-receiver"},{"type":"user","authorizableId_xss":"admin","authorizableId":"admin","name_xss":"Administrator","name":"Administrator","home":"/home/users/w/wFeT8_d9GMvkvT7eHVMg","isImpersonated":false}],"total":2}
As you can see the "type" property of the 2 objects in the json is "user" and the id of the user or name is represented by "authorizableId" property. We can simply check if the returned list of users in the json has the same name as the logged in user name.
Views
Replies
Total Likes
Hi Kunal,
Thank you, i got this now.
It really help.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes