Grails security filter all action but except one

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

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.

Answers

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 ->

        }
    }

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/27631800/grails-security-filter-all-action-but-except-one

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils