Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Get current logged in user in clientlibs AEM 6.4

Avatar

Avatar
Validate 50
Level 3
selvaganesh
Level 3

Likes

7 likes

Total Posts

172 posts

Correct Reply

0 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Boost 5
View profile

Avatar
Validate 50
Level 3
selvaganesh
Level 3

Likes

7 likes

Total Posts

172 posts

Correct Reply

0 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Boost 5
View profile
selvaganesh
Level 3

13-12-2018

How to get current logged in user in clientlibs  ,AEM 6.4

Replies

Avatar

Avatar
Validate 50
Level 3
selvaganesh
Level 3

Likes

7 likes

Total Posts

172 posts

Correct Reply

0 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Boost 5
View profile

Avatar
Validate 50
Level 3
selvaganesh
Level 3

Likes

7 likes

Total Posts

172 posts

Correct Reply

0 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Boost 5
View profile
selvaganesh
Level 3

13-12-2018

function getLoggedInUserID() {

        var currentUserId = "";

        var currentUserInfo;

        var CURRENT_USER_JSON_PATH = Granite.HTTP.externalize('/libs/granite/security/currentuser.json');

        var result = Granite.$.ajax({

            type: "GET",

            async: false,

            url: CURRENT_USER_JSON_PATH

        });

        if (result.status === 200) {

            currentUserInfo = JSON.parse(result.responseText);

            currentUserId = currentUserInfo.authorizableId;

        }

        return currentUserId;

    }

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

13-12-2018

Thanks for sharing.

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile
Ravi_Pampana
MVP

13-12-2018

In author mode, we can read the current user/details by below variable

CQ_User

CQ_User.data.userID

Screen Shot 2018-12-13 at 9.55.18 AM.png

Hope this helps

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

13-12-2018

Hi Ravi,

I've just checked this in 6.3 and found CQ_User.data.userID works only in Classic UI whereas Granite.HTTP.externalize('/libs/granite/security/currentuser.json'); Ajax approach is compatible with both UI.

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile
Ravi_Pampana
MVP

13-12-2018

Hi Arun,

Thanks for the details. But when I tried in AEM 6.4 and AEM 6.4 SP2 I am able to see CQ_User variable, not sure whether it is added back

Screen Shot 2018-12-13 at 10.21.09 AM.png

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

13-12-2018

Ahh ok, that means it is available in current version of AEM 6.4