Quantcast

spring-security-ui customization problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

spring-security-ui customization problem

kirk
I am attempting to customize the register controller in the spring-security-ui plugin and for some reason, the register method on the plugin controller is being executed instead of the register method on my controller.

I ran the "grails s2ui-override register testapp1" command to generate a register controller and gsp files in my application. I then added a "register" closure with the exact same signature. When I hit the register controller in the application (i.e. /register/register), my controller gets created but the register method on the plugin's register controller gets called instead of my controller.

I realize that the preferred Grails 2.0 way of controllers is with methods instead of closures but I don't want to change the plugin code. BTW, if I change from closures to methods, my register method gets called.  I'm using Grails 2.0 RC1 and the latest spring-security-ui plugin.

So from the plugin's Register controller:

class RegisterController extends AbstractS2UiController {

        static defaultAction = 'index'

        def mailService
        def saltSource

        def index = {
                [command: new RegisterCommand()]
        }

        def register(RegisterCommand command) {
               
                if (command.hasErrors()) {
                        render view: 'index', model: [command: command]
                        return
                }
        .
        .
        .
        .
****************************************************

My Register controller:

package testapp1

import grails.plugins.springsecurity.ui.RegisterCommand
import org.codehaus.groovy.grails.plugins.springsecurity.ui.RegistrationCode
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils

class RegisterController extends grails.plugins.springsecurity.ui.RegisterController {
       
                def register(RegisterCommand command) {
                       
                         println "In my RegisterController.register()"

                }

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: spring-security-ui customization problem

Abby
From the Grails documentation, i found this snippet. I think if you make this change, your problem should be solved.

If you prefer the Closure syntax or have older controller classes created in earlier versions of Grails and still want the advantages of using methods, you can set the grails.compile.artefacts.closures.convert property to true in BuildConfig.groovy:

grails.compile.artefacts.closures.convert = true


and a compile-time AST transformation will convert your Closures to methods in the generated bytecode.
Loading...