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

SOLVED

How to read id(9wMp6sGyejwQn-rzopsh) based on the user login programatically

kotireddy4b1
Level 2
Level 2

Can you please help me with how to read id(9wMp6sGyejwQn-rzopsh) based on the user login. How to EX: If admin user login then need to display this id: 9wMp6sGyejwQn-rzopsh

 

Screenshot 2021-07-18 at 9.32.52 PM.png

 

@Bimmi_Soi@KiranVedantam1992

1 Accepted Solution
Dipti_Chauhan
Correct answer by
Community Advisor
Community Advisor

Hi @kotireddy4b1 

 You should be simple able to get it from Authorizable 

Sample code snippet:

 Session session = resourceResolver.adaptTo(Session.class);
 UserManager userManager = resourceResolver.adaptTo(UserManager.class);
Authorizable auth = userManager.getAuthorizable(session.getUserID());

 from this you can simply get id or path of logged in user.

 

Thanks

Dipti

View solution in original post

1 Reply
Dipti_Chauhan
Correct answer by
Community Advisor
Community Advisor

Hi @kotireddy4b1 

 You should be simple able to get it from Authorizable 

Sample code snippet:

 Session session = resourceResolver.adaptTo(Session.class);
 UserManager userManager = resourceResolver.adaptTo(UserManager.class);
Authorizable auth = userManager.getAuthorizable(session.getUserID());

 from this you can simply get id or path of logged in user.

 

Thanks

Dipti

View solution in original post