Retriving details about the current user

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Retriving details about the current user

Ben Short-4
Hi,

Is it possible to retrieve details about the user making the request?

Example:

I want to allow users to register on my site. This will result in a
user node being created under /users possible with the node name equal
to their email address. For instance /users/[hidden email].

Once the user has registered and signed in they would be able to
access/edit content under their node accessible via link on a webpage.
While generating these links in my GET.jsp how can I find the
[hidden email] of the user making the request?

The users email address may not be the best node name probably better
to user first and last name or a unique user name. In fact looking at
the jackrabbit-usermanager bundel the name of the user supplied when
creating the user would be a good node name. But I digress.

How to get the username of the user making the request in my jsp file?

Regards

Ben Short

Reply | Threaded
Open this post in threaded view
|

Re: Retriving details about the current user

Alexander Klimetschek
On Tue, Oct 13, 2009 at 14:32, Ben Short <[hidden email]> wrote:
> How to get the username of the user making the request in my jsp file?

When logged in to the JCR (which is the default way in Sling), you can
get the user id from the current session:

session.getUserID();

To get the session, you can do two things:

Session session = currentNode.getSession();
Session session = resourceResolver.adaptTo(Session.class);

See also http://cwiki.apache.org/SLING/scripting-variables.html

Regards,
Alex

--
Alexander Klimetschek
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Retriving details about the current user

Ben Short-4
Thanks Alexander thats exactly what I needed.

2009/10/13 Alexander Klimetschek <[hidden email]>:

> On Tue, Oct 13, 2009 at 14:32, Ben Short <[hidden email]> wrote:
>> How to get the username of the user making the request in my jsp file?
>
> When logged in to the JCR (which is the default way in Sling), you can
> get the user id from the current session:
>
> session.getUserID();
>
> To get the session, you can do two things:
>
> Session session = currentNode.getSession();
> Session session = resourceResolver.adaptTo(Session.class);
>
> See also http://cwiki.apache.org/SLING/scripting-variables.html
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> [hidden email]
>