This website uses cookies to ensure you get the best experience on our website.

Skip to content
LOGO
  • Company

    About IGNEK

    Learn about our story and our mission.

    Careers

    We're hiring!

    We always looking for talented peoples. Join our team!

    Blogs

    The latest industry news, updates and info.

    Case Studies

    Take a closer look at the projects we've delivered

    Webinar

    Watch our latest organized webinar

    Get in touch with our HR team

    • hr@insights.ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Custom Enterprise Portal Development for flawless Solutions

    Dedicated Development Team

    Expand Teams, Optimize Development with Our Expertise

    Back-end Development

    Empowering your digital presence with robust backend development expertise

    Front-end Development

    Crafting engaging user experiences through expert frontend development

    Digital Transformation

    Embrace digital transformation by modernizing process

    SaaS Development

    Transform your business with SaaS Innovative Solutions

    Technologies

    Liferay Services

    Development & Customization

    Theme

    Upgradation

    Migration

    Proof of Concept

    Performance Tunning

    Architecture

    Support & Maintenance

    E-commerce

    Expert Advice

    React Services

    Enterprise Development

    Custom Application

    Single Page Application

    Architecture

    API Integration

    Migration

    Consulting

    Maintenance & Support

    Spring Boot Services

    Web Service

    MVC Web Development

    API Integration

    Security

    Migration

    Microservices

    Support & Maintenance

    AEM Services

    Consulting Service

    Site Development

    Migration & Upgradation

    Integration

    Maintenance & Support

    Custom Solutions

    Content Management

    Team Augementation

  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Transforming industries through cutting edge SaaS solutions.

    Customer Portal : Boost Business Productivity

    Streamline operations and enhance productivity with our Customer Portal solution.

    Liferay Based Intranet Portal

    Internal portal for company communication, collaboration and resources

    Integration

    Matomo Integration with Liferay

    Integrate Matomo to enable user interactions seamlessly.

    Microsoft Teams integration with Liferay

    Integrate to enable seamless collaboration, messaging within your portal.

    Jira Integration With Liferay

    Optimizes business operations by integrating with Jira.

  • Hire Us

    Liferay

    Get expert Liferay developers for seamless portal solutions.

    React JS

    Get expert ReactJS developers for dynamic web solutions.

    Web Developer

    Get custom web solutions from IGNEK's expert developers.

    Spring Boot

    Get top-notch Spring Boot developers for your project success!

    Healthcare

    Get top Healthcare Developers for cutting-edge medical software.

    MERN Stack

    Get expert MERN developers from IGNEK for custom, innovative project solutions.

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@insights.ignek.com
    • +91 6351576580
    • info@insights.ignek.com
    • Ahmedabad, Gujarat, India – 382470
SCHEDULE CALL
  • COMPANY
    • About
    • Case Studies
    • Blogs
    • Career
    • Webinar
  • SERVICES
    • Enterprise Portal Development
    • Dedicated Development Team
    • Back-end Development
    • Front-end Development
    • Digital Transformation
    • SaaS Development
  • SOLUTION
    • Customer Portal:  Boost Business Productivity
    • SaaS : Software as a Service
    • Liferay Based Employee Intranet Portal
  • TECHNOLOGY
    • Liferay Services
      • Liferay Development and Customization
      • Liferay Theme Development Service
      • Liferay DXP 7.4 Upgrade
      • Liferay Migration
      • Liferay Proof Of Concept
      • Liferay Performance Tuning
      • Liferay Architecture Design Service
      • Liferay Support And Maintenance Service
      • Liferay Ecommerce Development
      • Liferay Expert Advice
    • ReactJS Services
      • ReactJS Enterprise Application Development
      • ReactJS Custom Application Development
      • ReactJS Single Page Application Development (SPA)
      • ReactJS Applications Architecture
      • ReactJS API Integration
      • ReactJS Migration
      • ReactJS Consulting
      • ReactJS Maintenance and Support
    • Spring Boot Services
      • Spring Boot Web Development Service
      • Spring MVC Web Development
      • Spring Boot API Integration Service
      • Spring Boot Security
      • Spring Boot Migration Service
      • Spring Boot Microservices
      • Spring Boot Support & Maintenance Service
    • AEM Development Services
      • AEM Consulting Services
      • AEM Site Development
      • AEM Migration & Upgradation
      • AEM Integration Services
      • AEM Maintenance & Support
      • AEM Content Management
      • Custom AEM Solutions
      • AEM Team Augmentation
  • INTEGRATION
  • HIRE US
    • Hire Liferay Developer
    • Hire ReactJS Developer
    • Hire Spring Boot Developer
    • Hire Healthcare Developer
    • Hire Web Developer
    • Hire MERN Stack Developer
  • CONTACT US
  • Company

    About IGNEK

    Careers

    We're hiring!

    Blogs

    Case Studies

    Webinar

    Get in touch with our HR team

    • hr@insights.ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Dedicated Development Team

    Back-end Development

    Front-end Development

    Digital Transformation

    SaaS Development

    Technologies

    Liferay Liferay Services
    • Development & Customization
    • Theme
    • Upgradation
    • Migration
    • Proof of Concept
    • Performance Tuning
    • Architecture
    • Support & Maintenance
    • E-commerce
    • Expert Advice
    React React Services
    • Enterprise Development
    • Custom Application
    • Single Page Application
    • Architecture
    • API Integration
    • Migration
    • Consulting
    • Maintenance & Support
    Spring Boot Spring Boot Services
    • Web Service
    • MVC Web Development
    • API Integration
    • Security
    • Migration
    • Microservices
    • Support & Maintenance
    AEM AEM Services
    • Consulting Service
    • Site Development
    • Migration & Upgradation
    • Integration
    • Maintenance & Support
    • Custom Solutions
    • Content Management
    • Team Augmentation
  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Customer Portal : Boost Business Productivity

    Liferay Based Intranet Portal

    Integration

    Matomo Integration with Liferay

    Microsoft Teams integration with Liferay

    Jira Integration With Liferay

  • Hire Us

    Liferay

    React JS

    Web Developer

    Spring Boot

    Healthcare

    MERN Stack

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@insights.ignek.com
    • +91 6351576580
    • IGNEK
    • Ahmedabad, Gujarat, India – 382470
  • SCHEDULE CALL

Login and Logout Events

  • Liferay
  • November 18, 2025

Share On :

Introduction

Liferay provides a feature to execute code before and after specific events, such as Login and Logout, as well as services. Here we are discussing the login and logout events.

Prerequisites
  • Liferay

  • Basic knowledge of Liferay

Purpose
  • Managing session data

  • Track user activity

  • Redirect User

  • Clearing session data

  • Show personalized data

Steps to create pre-login events.

Step 1 : Create a module

  • First, create the service module in the Liferay workspace.

  • In the reference Image, we have a constant file for all the strings used in code.

Folder Structure

Step 2: Register a LifecycleAction

  • To register a lifecycle action, add the LifecycleAction class in the Component annotation.

  • Initialize the key in an OSGI component so Liferay can recognize whether it is a pre-event or post-event for login or logout.

  • The LifecycleAction class in Liferay is an interface located within the com.liferay.portal.kernel.events package. It serves as a mechanism to define actions that are executed during specific lifecycle events within the Liferay DXP platform.
				
					@Component(
	property = {
		"key=login.events.post"
	},
	service = LifecycleAction.class
)
				
			
  • For login and logout events, keys will be changed as per the table.

Events 

Login

Logout

Pre 

login.events.pre

logout.events.pre

Post

login.events.post

logout.events.post

  • Pre-login events execute before a user is authenticated and run custom logic such as modifying login data or applying extra security. 

  • Post-login events execute after a successful login, allowing for actions like redirecting the user, logging user activity, or initializing session data.

Step 3: Override methods of the LifecycleAction interface

  • After registering the services with OSGi, we need to implement a LifecycleAction interface.

  • Once we implement the interface, we need to override its methods.
  • Here, the processLifecycleEvent method is overridden. 

  • This method contains the custom logic for login or logout events.

Note :

Here, an Activity object is created to store the user’s activity data.

The activity object contains three fields : 

  1. IPAddress

  2. Activity Type (Type of activity the user is performing)

  3. Detail (Email or any other information of the user)

Here are some reference images of the activity object.

Object Details
Object Fields
  • The processLifecycleEvent method contains the logic of fetching all the fields of the activity object and adding an entry in the activity object to monitor users’ activity when a user logs in.

EmployeeLoginConstant.java

				
					package com.employee.login.constant;

public class EmployeeLoginConstant {

	public static final String ACTIVITY = "C_ACTIVITY";

	public static final String ACTIVITY_TYPE = "activityType";
	
	public static final String DETAILS = "details";
	
	public static final String IGNEK_INTRANET = "Ignek";
	
	public static final String IP_ADDRESS = "iPAddress";

	public static final String LOGIN ="LOGIN";
	
	public static final String LOGOUT = "LOGOUT";
}

				
			

EmployeeLoginEvents.java

				
					package com.employee.login.events;

public class EmployeeLoginEvents implements LifecycleAction {

	@Override
	public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
		
		try {
			log.info("Post Login event is Started");
			
			HttpServletRequest request = portal.getOriginalServletRequest(lifecycleEvent.getRequest());
			String ipAddress = request.getRemoteAddr();
			log.info("Client IP Address: " + ipAddress);
			
			long companyId = portal.getUser(request).getCompanyId();
			
			Group group = groupLocalService.getGroup(companyId, EmployeeLoginConstant.IGNEK_INTRANET);
			long groupId = group.getGroupId();
			
			ObjectDefinition objectDefinition =
				    objectDefinitionLocalService.fetchObjectDefinitionByExternalReferenceCode(
				    		EmployeeLoginConstant.ACTIVITY,companyId);
		
			if (Validator.isNotNull(objectDefinition)) {
				ServiceContext serviceContext = new ServiceContext();
				Map<String, Serializable> values = new HashMap<>();
				values.put(EmployeeLoginConstant.ACTIVITY_TYPE,EmployeeLoginConstant.LOGIN);
				values.put(EmployeeLoginConstant.DETAILS, portal.getUser(request).getEmailAddress());
				values.put(EmployeeLoginConstant.IP_ADDRESS, ipAddress);
				log.info("Values are set for activity");
				
				ObjectEntry objectEntry = objectEntryLocalService
					.addObjectEntry(portal.getUser(request).getUserId() ,groupId,
						objectDefinition.getObjectDefinitionId(), values ,serviceContext);
				
				log.info("Object entry created with ID: " + objectEntry.getObjectEntryId());
			}
		} catch(Exception e) {
			log.info("Error occured while generation activity entry "+ e);
		}
	}

	private static final Log log = LogFactoryUtil.getLog(EmployeeLoginEvents.class);

	@Reference
	private ObjectEntryLocalService objectEntryLocalService;

	@Reference
	private ObjectDefinitionLocalService objectDefinitionLocalService;
	
	@Reference 
	private GroupLocalService groupLocalService;
	
	@Reference
	private Portal portal;
}

				
			

Code Explanation :

  1. First, fetch the HttpServletRequest from the lifecycleEvent object.
  2. Fetch an activity object definition with the help of companyID and ExternalReferenceCode.
  3. After fetching the object definition, create a Map<String, Serializable> data-type variable to store all the values.
  4. At last, add values to the object entry.

Now, whenever a user logs in, an entry in the activity object will be created with these fields : 

  1. Activity ID
  2. Details (email ID of that user)
  3. IPAddress (IPAddress of the user device)
  4. Activity type 

For reference, here is the image of the activity object data stored in the database.

Activity-table-2
Activity-table-1

This way, you can map the users’ activity while the user logs in and write any custom logic according to your business requirements.

Conclusion :

Log-in and Log-out events are for customizing your Liferay portal according to your needs. These particular events can be used for monitoring user activity, clearing data, or redirecting the user.

Loading...

Related Blogs

November 28, 2024
Google Login Integration In Liferay
Google Login Integration In Liferay
December 11, 2019
Customize the look feel of login portlet in Liferay Cover Image
Customize the look & feel of login portlet in Liferay
November 22, 2024
possible ways to customize the Liferay
Possible Ways to Customize the Liferay
Loading...

Featured Projects Portfolios

October 4, 2023
Telecom Public Website _ Multilingual, E-Commerce, and Advanced Features
Telecom Public Website : Multilingual, E-Commerce, and Advanced Features
June 19, 2024
Music License Management Portal _ Onboarding & Data Integrity
Music License Management Portal : Onboarding & Data Integrity
November 25, 2024
Liferay DXP Based Intranet Portal Migration from 7.0 to 7.4
Liferay DXP Based Intranet Portal Migration from 7.0 to 7.4

Digital Solutions for Your Business with IGNEK

4.9

5.0

5.0

5.0

LOGO

Making the world a better place through constructing elegant hierarchies

COMPANY

  • About
  • Career
  • Case Study
  • Blogs

SERVICES

  • Enterprise Portal Development
  • Dedicated Development Team
  • Back-end Development
  • Front-end Development
  • Digital Transformation
  • SaaS Development

HIRE US

  • Liferay
  • Spring Boot
  • ReactJS
  • Healthcare
  • MERN Stack
  • AEM

CONTACT

  • info@insights.ignek.com
  • info@insights.ignek.com
SALES
  • sales@insights.ignek.com
  • (+91) 635 157 6580
CAREER
  • hr@insights.ignek.com
  • (+91) 932 849 5160
  • E 910-912, Ganesh Glory 11, Jagatpur Road, SG Highway, Ahmedabad, Gujarat - 382470

© 2018-2026 IGNEK, Inc. All rights reserved

Linkedin Facebook X-twitter Instagram