On 02/27/2011 12:59 AM, Paul Libbrecht wrote:
> Hello fellow developers,
>
> what is the best way to listen to login events?

If you want to listen to active clicking on the login button, then you 
can listen to the "login" ActionExecutionEvent.

> Is there a notification of some sort?
> For any session creation or destruction?

javax.servlet.http.HttpSessionListener but HTTP Sessions are not a good 
indication of logins/logouts. Actually (and this is very bad) loging in 
and out keeps the same session.

It's hard to know what exactly is a login, since the current user is 
reauthenticated for each request by checking the cookies sent. The login 
process simply sends those cookies to the client, it doesn't really mark 
somewhere that JohnDoe just logged in.

Yet, there are some optional traces you could use:
- if you enable statistics, then its Visit objects can track when a user 
made the first request in a new visit
- if you leave the authentication cache on (as it is by default since a 
while ago) you can watch (via HttpSessionAttributeListener) when the 
user authentication token is added to the session
-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to