This content has been marked as final.
Show 2 replies
-
1. Re: how to get user ID of logged in user ?
idyoshin Feb 22, 2010 11:16 AM (in response to narendra.narendra_00001.yahoo.co.in)well there is 2 ways to do this.
1. create an event listener for Identity.EVENT_POST_AUTHENTICATE listener(Identity loggedInIdentity), that will outject to the session scope current user id;
2. another one create a stateless component with method
User getUser(String username) { javax.persistence.Query q = getEntityManager().createQuery("SELECT o FROM User o WHERE o.username = :username"; q.setParameter("username", username); return (User )q.getSingleResult(); }
and inject it in each Component you require loggedInUser.
I assume that you use JPA users not a LDAP. But with LDAP - it's similar.
Regards,
Ilya Dyoshin
-
2. Re: how to get user ID of logged in user ?
narendra.narendra_00001.yahoo.co.in Feb 22, 2010 1:19 PM (in response to narendra.narendra_00001.yahoo.co.in)Thanks very much Ilya.
Yes I am using JPA Users.
Regards,
Narendra