This content has been marked as final.
Show 5 replies
-
1. Re: Retrieving the logged in user from session context
luxspes Sep 24, 2009 5:01 PM (in response to yannfromparis)To obtain the current user name:
if(Identity.instance().isLoggedIn()) return Identity.instance().getPrincipal().getName();
-
2. Re: Retrieving the logged in user from session context
yannfromparis Sep 24, 2009 7:18 PM (in response to yannfromparis)Francisco, thanks for your reply. However, I've found in the seamspace source code just what I need. The trick is to use an Observer on the EVENTUSERAUTHENTICATED event, to put a reference in the session context.
Yann
-
3. Re: Retrieving the logged in user from session context
luxspes Sep 24, 2009 9:26 PM (in response to yannfromparis)Why do you reinvent the wheel? If Identity.instance() already allows you to retrieve the currently loggeding user I see not point it wasting memory by storing that information twice in the current session...
-
4. Re: Retrieving the logged in user from session context
swd847 Sep 25, 2009 8:12 AM (in response to yannfromparis)Sometimes you want the actual User entity (or at least the primary key), e.g. I have a system where the unique representation of a user is (domain_id, username) so just the username is not enough to know who is logged in. -
5. Re: Retrieving the logged in user from session context
wadhah Feb 18, 2011 10:45 AM (in response to yannfromparis)
Francisco Peredo wrote on Sep 24, 2009 17:01:
To obtain the current user name:if(Identity.instance().isLoggedIn()) return Identity.instance().getPrincipal().getName();
How to obtaint the User ?? because i need the userId stored on the database ?