Search code examples
hookliferayregistrationliferay-6user-registration

Creating additional validation steps for user registrarion in Liferay


I'm trying to add some validation steps to the user registration process in Liferay, but can't seem to find the right place to do so.

As far as I know, there's no event where I could add my own code when creating a new user (contrary to the login process where we have the "login.events.post" event).

Is there any way to do this?

UPDATE: we're trying to avoid redoing what liferay already does, even if creating a new user registration portlet makes a lot of sense.

I just found out about the "servlet.service.events.pre" event and thought that a hook could be created on the CreateAccountAction class to add my own validation, but I'm not getting much from liferay's documentation on this topic. Any ideas/suggestions/links would be greatly appreciated.


Solution

  • Ended up creating a hook on create_account.jsp and used ajax to do some validations (together with server-side validation) on the new user's info. Then created another hook on login.jsp (which is executed right after liferay finishes creating the new user account).

    When login.jsp is loaded, liferay evaluates if a user was added before landing on this page:

    <c:if test='<%= SessionMessages.contains(request, "user_added") %>'>
    

    It's right there where we added a second round of our own validations on the newly created user.