* Depending on which type of app event we will log one or other thing.
*/
public void onApplicationEvent(ApplicationEvent ev) {
if (ev instanceof AbstractAuthenticationEvent) {
AbstractAuthenticationEvent e = (AbstractAuthenticationEvent) ev;
if (e instanceof InteractiveAuthenticationSuccessEvent
|| e instanceof AuthenticationSuccessEvent
|| e instanceof AuthenticationSwitchUserEvent) {
try {
UserDetails userDetails = (UserDetails) e
.getAuthentication().getPrincipal();
User user = _userRepository.findOneByUsername(userDetails.getUsername());
user.setLastLoginDate(new ISODate().toString());
_userRepository.save(user);