In my User.groovy domain class, I have added the field String email which I want to capture on registration. I have these constraints defined:
email email:true, blank: false, maxsize: 255, unique: true
When I register, if I try to reuse an existing username, I get a nice error next to the username field that says the username is taken. I see in the generated HTML that this comes from
<span class='s2ui_error'>The username is taken</span>
However when I try to reuse an existing email address, I get a black pane with yellow text in the top right of my screen that says:
"sorry there was a problem processing your registration".
This message only appears if there are no other errors.
I would like to cause a duplicate email error to generate a field error similar to the duplicate user name error. I cannot seem to locate where these additional tags are generated.
Thanks in advance for any advice.
After a lot of trial and error, I took what I had learned and "went back to the drawing board". I decided that the best possible outcome would be to make this work simply by replacing the default RegisterCommand.groovy that "comes with" Spring Security UI with one of my own that includes the check for duplicate email.
I also decided to get rid of the stub RegisterController.groovy provided by the s2ui-override process, just in case that interfered.
This approach works. The new
RegisterCommand.groovy
goes inin the project directory and it looks like this:
Two comments worth making:
One comment perhaps not work making - in all the years that this wonderful Spring Security UI has been available, why hasn't this already been discovered and documented?