Auditing the sucessful logged-in users in liferay


In Liferay we have some events to like application startup, global events, login events and many more.

If we want to audit the login user on which IP address he logged-in in liferay we have events like
1.login.events.pre
2.login.events.post


login.events.pre : Which Executes Before Login Action.
login.events.post: Which Excutes After Login.

we want to track the user login on which IP Address used so we will write the login.events.post which will be execute after login completes.

In Portal.Properties
login.events.post = com.sample.hook.LoginSuccessAudit.


Create a class called LoginSuccessAudit
public class LoginSuccessAudit extends Action {
@Override
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {

                   User user = PortalUtil.getUser(request);
                   System.out.println("IP Address is"+user.getLoginIP());

            }

}



By this we can audit the successfully logged-in users.

Comments

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate