How can I access the user login details in publish?
How can I get get user details in publish intance?
@SlingObject
private SlingHttpServletRequest request;
private User user = null;
/**
* Initial method to get the user id
*/
@PostConstruct
public void initModel() throws ParseException {
ResourceResolver resourceResolver = this.request.getResourceResolver();
final Session adminSession = resourceResolver.adaptTo(Session.class);
final UserManager userManager = resourceResolver.adaptTo(UserManager.class);
try {
user = (User) userManager.getAuthorizable(adminSession.getUserID());
} catch (RepositoryException e) {
LOGGER.error("RepositoryException While getting userID");
}
}
I tried getting user using current request and get details
user.getProperty("./profile/city")[0].getString(); which will return the string value. I tried in my author instance which was working fine. But same when I tried in publish instance not able to get the value.
Is there any other way to get the user login details in publish?
