Hi Tauren,

You could implement an AuthenticationListener - I typically like to do
this for these kinds of operations.

Since Shiro does not count remember me as a true authentication, the
AuthenticationListener will not be triggered for remember me events.
To do that you would also need to implement your own
RememberMeManager.  Typically subclassing the default one and updating
the timestamp in the getRememberedPrincipals method would work:

@Override
public PrincipalCollection getRememberedPrincipals(Map subjectContext) {
    PrincipalCollection principals =
super.getRememberedPrincipals(subjectContext);
    if ( principals != null ) {
        int userId = principals.getPrimaryPrincipal();
        //update the last login timestamp for user with this id here
    }
}

The above method is called only if the current Subject/session does
not yet have an identity associated with it.

The AuthenticationListener + the above overridden method should do it!

Cheers,

Les

On Thu, Apr 15, 2010 at 8:37 PM, Tauren Mills <[email protected]> wrote:
> What would be the best way to update properties of a member on successful
> authentication? Basically, there is a Member.lastLogin property that I want
> updated with the current date every time a member comes back to a site and
> logs in.  However, this should also support rememberme authentications. I
> don't necessarily want to update the lastLogin property on every single
> interaction the user has on the site, just once for each session.
> Is there some technique in Shiro to do this, a callback of some sort, or
> some other method? Or should I be doing this in my application?
> Also, I can't seem to view much of the documentation. All the links on the
> following page require an Apache login. Is it supposed to be this way?
> http://incubator.apache.org/shiro/core.html
> Thanks!
> Tauren
>
>

Reply via email to