I'm gonna create a security filter for my project. I check if !session.user then redirect to action error
.
Here is my current code:
all(controller: 'accounting|installation|installer|sales|service|serviceOrder|document', action: '*') {
before = {
if (!session.user) {
redirect(controller: 'installation', action: 'errors')
return false
}
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
However the point is that session.user
being created in controller 'installation'
and action 'index'
. So how can I filter without index action
?
Any suggestions will be appreciated. Thanks.
Try this
all(controller: 'accounting|installation|installer|sales|service|serviceOrder|document', action: '*') {
before = {
if (!(controllerName == 'installation' && actionName == 'index')) {
if (!session.user) {
redirect(controller: 'installation', action: 'errors')
return false
}
}
}
after = { Map model ->
}
afterView = { Exception e ->
}
}