Skip to main content

I deleted Liferay's default guest account now what!!!

I recently had the opportunity to work with Liferay Portal version 6.2 ga4. Liferay is a platform that allows you to create dynamic web applications using Portal technology where you can create Java Portlets.

Liferay supports many different relational database systems. Our project utilized PostgreSQL. Depending on how you install Liferay, you can either pre-populate the database or let Liferay create the database during initial start up. 

In our project, we had the need to synchronize users to our Liferay instance from other datasources specifically from an Oracle database instance. In order to handle this synchronization, we relied on Liferay's MessageListener interface. This interface allowed us to hook into Liferay's scheduler mechanism so that we were able to use cron style scheduling. 

In this implementation, we queried our source database and used Liferay's API to insert, update, and delete users and roles into Liferay. During delete, we had logic to skip default Liferay users such as default admin accounts. We did not realize there was another account called "guest" and this account was tied to the public pages where admin accounts use to login to the console. When we ran our first synch job, we noticed that this guest user was deleted and we could no longer get to the admin console because the public page (to login) was no longer rendering because the user "guest" was no longer in the system. 

We did a little bit of digging and found out that guest user must be (obviously) deleted. In order to recover from this, we had to manually insert the user back into Liferay's own schema. Here are the SQL statements we used. 

 insert into User_ (userId, companyId, createDate, modifiedDate, defaultUser, contactId, password_, passwordEncrypted, passwordReset, screenName, emailAddress, greeting, firstName, middleName, lastName, loginDate, failedLoginAttempts, agreedToTermsOfUse, status)   
 values (20159, 20155, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, TRUE, 20160, 'password', FALSE, FALSE, '20159', 'default@liferay.com', 'Welcome!', '', '', '', CURRENT_TIMESTAMP, 0, TRUE, 0);  
 insert into Contact_ (contactId, companyId, userId, userName, createDate, modifiedDate, accountId, parentContactId, firstName, middleName, lastName, male, birthday)   
 values (20160, 20155, 20159, '', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 20157, 0, '', '', '', TRUE, '01/01/1970');
commit;  
Once these statements were executed against our PostgreSQL database, we had to restart Liferay to fully fix the problem. I believe Liferay on the fly creates the remaining necessary database objects when the public (login) page is visited by the guest user. 

This was a good learning experience for our team I thought of sharing. 

Comments