Grails security filter doesn39t work with 2 controllers

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I m using grails 2.4.3, created a security filter. I had 3 controller in my project name: admin, login and report. So I added following to the filter:

def filters = {
        all(controller:  Admin , action:  * ) {
            before = {
                if (!session.company) {
                    redirect(controller:  login , action:  auth )
                    return false
                }
            }
            after = { Map model ->

            }
            afterView = { Exception e ->

            }
        }
    }

I mean that any actions from admin controller, if !session.company, a page will be redirected into the auth action in a login controller.

Now I d like to add a controller report into this filter, how do I do that? I tried all(controller: [ Admin , Report ], action: * ) but it doesn t work.

Any help will be appreciated. Thanks

Answers

Use pipe symbol to add multiple controllers, like

def filters = {
    all(controller:  Admin|Report , action:  * ) {
        ...
    }
}

http://stackoverflow.com/questions/8941249/how-to-define-mutliple-distinct-controllers-in-grails-2-filter http://stackoverflow.com/questions/8941249/how-to-define-mutliple-distinct-controllers-in-grails-2-filter

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/26879441/grails-security-filter-doesnt-work-with-2-controllers

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils