Reputation: 699
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
Upvotes: 2
Views: 581
Reputation: 126
Use pipe symbol to add multiple controllers, like
def filters = {
all(controller: 'Admin|Report', action: '*') {
...
}
}
Ref# How to define mutliple distinct controllers in Grails 2 filter?
Upvotes: 7