Get user on Touch UI | Community
Skip to main content
antond26624417
Level 2
Sep 28, 2018 2:34 PM UTC
Solved

Get user on Touch UI

I'm currently try to find the way how I can restrict the using "source mode" for RTE only for administrator.
So I need to get a current user in js. I found out that for Classic UI we can use "CQ.User.getCurrentUser(). What is the way to get this User on Touch UI?
Or it will be better to use Java API for this and then make ajax call from jquery.
Thanks in advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
aneetaroraAccepted solution
Employee
Sep 28, 2018 4:22 PM UTC

Hello antond26624417​

You can create a rep:policy node on your component to restrict this access.

1) Go to /useradmin

2) Deny permissions for everyone group on the misctools under your RTEplugins node

3) Admin user, and any member of administrator's group will have access to this node and therefore the sourceedit feature as well.

Hope this approach helps.

Regards,

Aneet Arora

7 replies

antond26624417
Level 2
Oct 2, 2018 12:39 PM UTC

aneeta45259594​ It would be the best one for our case!
Thanks both of you! smacdonald2008​

Translate
smacdonald2008
Level 10
Sep 28, 2018 5:34 PM UTC

In that article that  Sreekanth suggest you look at - you can see an example of using JavaScript.  In this user case - you want to modify RTE source view based on the user. To do this - you would not use a Java API.

Translate
antond26624417
Level 2
Sep 28, 2018 5:30 PM UTC

smacdonald2008​ Not sure this object exist for me, since It always returns null.
Also I need to check that this user should belong to "administrators" group.

It's not clear how we can use javascript  in comparison with Java API.

Translate
aneetaroraAccepted solution
Employee
Sep 28, 2018 4:22 PM UTC

Hello antond26624417​

You can create a rep:policy node on your component to restrict this access.

1) Go to /useradmin

2) Deny permissions for everyone group on the misctools under your RTEplugins node

3) Admin user, and any member of administrator's group will have access to this node and therefore the sourceedit feature as well.

Hope this approach helps.

Regards,

Aneet Arora

Translate
smacdonald2008
Level 10
Sep 28, 2018 3:46 PM UTC

Our touch ui expert relied -

Here is a sample http://experience-aem.blogspot.com/2018/07/aem-64-touch-ui-show-checked-out-user-in-content-fragment-editor.html

    function getLoggedInUserID(){

        return window.sessionStorage.getItem("granite.shell.badge.user");

    }

Translate
antond26624417
Level 2
Sep 28, 2018 3:41 PM UTC

smacdonald2008​ Thanks!

Translate
smacdonald2008
Level 10
Sep 28, 2018 3:35 PM UTC

This use case will be implemented via JS.

I am talking to our touch ui experts to get more details for you!

Translate