I have a filter that i want to filter every action except ONE that brings me to login page.
If i filter all pages with some condition then even the LOGIN page too get filtered and so it stuck in infinte loop as condition not fulfilled (User not Logged IN).
session.getAttribute("CurrentEmployeeIds") it tell whether user is logged in or not
My filter here:
class LoginFilters {
def filters = {
all(controller:'dashboard', action:'*') {
before = {
if (session.getAttribute("CurrentEmployeeIds")==null) {
redirect(controller:"site",action:"index")
return false
}
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}
}
I want to filter in such a way that it don't filter controller:"site",action:"index"
this url and filter everything else.
thanks in advance.
You can invert filter rule, like:
def filters = {
allExceptIndex(controller:"site",action:"index",invert:true) {
before = {
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}
See docs http://grails.org/doc/latest/guide/theWebLayer.html#filters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With