Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

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

Avatar

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@Kiran_Vedantam

1 Accepted Solution

Avatar

Correct answer by
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

Avatar

Correct answer by
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