Search code examples
grailsspring-securityoverridingcontrollers

Override controller from Grails Plugin


I was using Grails 2.0.4 and there was a LoginController in a plugin project that I was using instead of SpringSecurity's Login Controller.

Now I am migration to Grails 2.4.2 and it's not working anymore.

It worked when I put my controller inside of the project, but I'd like to put it back in the plugin project.

Any ideas on how to force it?


Solution

  • In your URL mapping you can be explicit about which login controller you are mapping to:

    // grails-app/conf/UrlMappings.groovy
    class UrlMappings {
        static mappings = {
            '/alphaLogin' {
                controller = 'login'
                plugin = 'alpha'
            }
    
            '/betaLogin' {
                controller = 'login'
                plugin = 'beta'
            }
        }
    }  
    

    Of course you don't have to provide a mapping to both of them. You can just map to the one you want and provide no route to the other.