Ray
Ray

Reputation: 6115

Extending Spring Security UI plugin (and plugins in general)

The Spring Security UI plugin, among other things, provides a registration page. On this page are 4 fields: username, email, password, and verify-password. It uses a regular architecture of controller and gsps. Staying with a single page registration for the user, I need to add a bunch of fields -- e.g. address, payment info, etc.

Any thoughts / recommendations on how to extend this plugin's page, so that I can get updated versions and incorporate them without too much re-integration. It's almost like one part of the page should go to the UI controller, and the other parts of the page should go to my controller. Note the UI controller usees regular forms (i.e. not ajax).

Thanks

Upvotes: 0

Views: 707

Answers (2)

Dónal
Dónal

Reputation: 187399

Assuming you used the s2-quickstart script to create the domain classes, controllers, and GSPs, you have 2 options for customising the User domain class

  • add your custom properties (address, payment info, etc.) directly to the User domain class created by the plugin
  • create your own User domain class that extends the one generated by the plugin. Add your custom properties to the subclass

According to this article, the latter approach is preferable because:

because it allows you to easily update the generated user domain class if its template ever changes. It also means you don't overly pollute your domain model with Spring Security specifics. On the downside, you have to deal with domain class inheritance, although the cost is pretty minimal.

You'll also need to add the custom fields to the GSPs. The controller actions probably won't require any modifications.

Upvotes: 1

lo_toad
lo_toad

Reputation: 535

To custom configure the Spring Security UI plugin I'd first of all have a look at the existing plugin code to get a handle on how it works and then run the override scripts that you require as detailed at:

http://burtbeckwith.github.com/grails-spring-security-ui/docs/manual/guide/10%20Customization.html

In your case you'd need:

grails s2ui-override register com.my.packagename

Jim.

Upvotes: 2

Related Questions