cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a user's last login date?

sdeyres
Champ in-the-making
Champ in-the-making

Hi,

I'd like to get a user's last login date. I searched the forum, and based on this thread (Re: get last login?​ ), it appears that I have two solutions to do this: enable audit (which seems a bit overkill to just get the last login date), or create a new aspect and extend the LoginBean to update the user's properties on authentication.

I created a custom LoginBean, but I am not able to find which configuration file I should update/create to use this custom bean in place of the default one. The link provided in the thread I am refferring to seems to be out of date. Can anyone point me in the right direction? FYI, I'm working on Alfresco 5.1.

Many thanks!

Sylvain.

12 REPLIES 12

You're right.

You can try overwriting following Spring bean:

   <bean id="authenticationComponent" class="org.alfresco.repo.security.authentication.AuthenticationComponentImpl">

by using your customised class:

   <bean id="authenticationComponent" class="com.foo.repo.security.authentication.LoggerAuthenticationComponentImpl">

and then override that authenticateImpl() method extending from org.alfresco.repo.security.authentication.AuthenticationComponentImpl

Hyland Developer Evangelist

I've wrote a quick sample to include a custom authenticator for login as first component in authentication chain. Please, check GitHub - angelborroy/alfresco-logger-authenticator: Custom authenticator for Alfresco It's not perfect, but can be used as reference.

Probably it's a better idea to implement Axel Faust​ approach, but I have no experience on that kind of customisation.

Hyland Developer Evangelist

kaynezhang
World-Class Innovator
World-Class Innovator

Almost like this,But Audit component is recommended.

Audit component provides  feature to track user activities include user login .And Audit data is accessible via the AuditService ,audit web scripts,So you don't need to implement your own.It is less intrusive than cusomized authentication.

Alfresco's default audit configuration already persists login success, login failure and logout events data.But it also persist more other data for general use.

If you only need login data,you can customize your configuration using alfresco-audit-example-login.xml.sample as an example.

About how to customize audit ,you can refer to http://docs.alfresco.com/5.1/references/dev-extension-points-audit.html