how get the user profile path(/home/users/username/profile) from the session? | Community
Skip to main content
Level 2
May 24, 2018
Solved

how get the user profile path(/home/users/username/profile) from the session?

  • May 24, 2018
  • 5 replies
  • 5212 views

I have got the session from the repository login (using username and password), now how to access the profile of the user from the session(/home/users/username/profile). In the end, I need user properties. The request could not be adopted to user properties since its still pointing to the anonymous user.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Peter_Puzanovs

Dear Sharat,

Thank you for your quick response,

You should be able to adapt org.apache.jackrabbit.api.JackrabbitSession to Authorisable[1] and retrieve property you want.

E.g. instead of adapting to request, adapt to the session which holds user information you want to present.

[1] Authorizable (Apache Jackrabbit 2.6.10 API)

Regards,

Peter

5 replies

Peter_Puzanovs
Community Advisor
Community Advisor
May 24, 2018

Dear Sharat,

Just to clarify,

When request comes in the user is not authenticated and is anonymous user. E.g. did not do any authorisation.

You want to serve user properties of another user(possibly system user) who is authenticated into repository to anonymous user?

Regards,

Peter

Level 2
May 24, 2018

When the request comes in, the user is trying to signup. I want to access the same user properties( Node )  from the session which i got from the repository login (which call the External login module and creates the same user in aem) .

Peter_Puzanovs
Community Advisor
Peter_PuzanovsCommunity AdvisorAccepted solution
Community Advisor
May 24, 2018

Dear Sharat,

Thank you for your quick response,

You should be able to adapt org.apache.jackrabbit.api.JackrabbitSession to Authorisable[1] and retrieve property you want.

E.g. instead of adapting to request, adapt to the session which holds user information you want to present.

[1] Authorizable (Apache Jackrabbit 2.6.10 API)

Regards,

Peter

Amit-Tiwari
Level 4
May 24, 2018

I dont know why you need the path but you can get the value,

I am getting logged in user property like this..(i am using AEM 6.2 )

Session session = slingRequest.getResourceResolver().adaptTo(Session.class);

UserManager userManager = AccessControlUtil.getUserManager(session);

if (session != null) {

final User currentUser = (User) userManager.getAuthorizable(session.getUserID());

userEmail = currentUser.getProperty(USER_EMAIL) != null ? currentUser.getProperty(USER_EMAIL)[0].getString() : null;

userName = currentUser.getProperty(USER_NAME) != null ? currentUser.getProperty(USER_NAME)[0].getString() : null;

here

USER_NAME = "./profile/familyName";

USER_EMAIL = "./profile/email";

rest properties you can look in crx /home/users/geometrixx/aparker@geometrixx.info/profile

same way you can get others also

Level 2
May 24, 2018

Thanks !!

This is what i came up with

JackrabbitSession jaSession = (JackrabbitSession) session;

UserManager auth = jaSession.getUserManager();

Authorizable authorizable = auth.getAuthorizable(session.getUserID());

Then u can easily access the user path from there.