Heads up! These docs are for Portofino 3, which is a legacy product. Check out Portofino 4!

Posted by Giampiero Granatella
on 18th February, 2010


This is the fourth tutorial of the user management series. In this tutorial we are going to explore user self-registration: a functionality that is often required by public web apps but is quite difficult to implement or even integrate with existing Java libraries.


A prerequisite is to have user management enabled and the email parameters configured as explained in the first tutorial. Check the presence of the following lines (customized as needed) in your portofino-custom.properties:

model.users.enabled=true
mail.smtp.host=smtp.gmail.com
mail.smtp.port=465
mail.smtp.login=your_account@gmail.com
mail.smtp.password=your_password
mail.smtp.ssl.enabled=true

Enable and configure self registration

To enable self registration you have to add following parameter:

model.users.registration.auto.enabled=true

Setting only this parameter  allows users to self register and immediately log on to the system.
If you also want that self-registrations be moderated by user administrators, set:

model.users.registration.moderated.enabled=true

With this flag set, self-registered users have to wait for the activation from an administrator.

How users self register

With self registration enabled, you'll find a new link called "Register" in the top right corner. Click on it.

A self-registration page is presented.

Enter the fields as required: login, password and email. Click on create to complete your registration.

Portofino will check:

  • that the login and the email are unique in the application
  • that passwords match and are compliant with what you specified in the portofino-custom.properties. 

Click on "Create". You'll be presented with a confirmation page.

The last step is to verify your registration. A confirmation email with the following link is automatically sent to you account:
"Please go to http://www.example.com/VerifyEmail.action?token=... to complete your registration"
Click on the link (or copy it in your browser) to complete the registration.

Customized User class

There are situations where you need to customize the User class. For instance you may want to add new attributes for "name" and "surname".
Self registration can handle this situation and prompt the user for the extra attributes. The only requirement is that those attributes are flagged as required in the "User" class.

Further readings

Previous tutorials in the user management series: