events
login
Developer
Legacy
How to listen login or logout events?
Question
How to enable the listening of Jahia Login/Logout system events?Answer
The fireLoginEvent
and fireLogoutEvent
are enabled by default since Digital Factory 7.0.0.2 in the jahia.properties
file.
The ApplicationListener
interface can be sued to listen to these two events as mentioned in our below Tech wiki :
- https://academy.jahia.com/documentation/techwiki/misc/events-rules-jobs#System_events​
- http://docs.spring.io/spring/docs/3.1.x/javadoc-api/org/springframework/context/ApplicationListener.html
Here is an example of two classes implementing the ApplicationListener interface:
package org.jahia.modules;
import org.jahia.params.valves.LoginEngineAuthValveImpl.LoginEvent;
import org.springframework.context.ApplicationListener;
public class MyLoginListener implements ApplicationListener<LoginEvent> {
@Override
public void onApplicationEvent(LoginEvent e) {
System.out.println("Test onApplicationEvent (loginEvent)");
}
}
package org.jahia.modules;
import org.jahia.bin.Logout.LogoutEvent;
import org.springframework.context.ApplicationListener;
public class MyLogoutListener implements ApplicationListener<LogoutEvent> {
@Override
public void onApplicationEvent(LogoutEvent e) {
System.out.println("Test onApplicationEvent (logoutEvent)");
}
}