Hi,
I have a requirement that when session expires, need to redirect to home page. For this I have written Filter and It works fine for Browser Requests, but doesn't work for Ajax Request. I mean It works, it opens the home page in a popup window (Ajax call happen on mouse hover - popup window). But I want to redirect to browser window.
Appreciate your help !!
import org.codehaus.groovy.grails.commons.ApplicationHolder;
class SecurityFilters {
def authenticateService
def filters = {
notLogin(controller:'login', invert:true) {
before = {
def principal = authenticateService.principal()
def currUser = (principal && principal != 'anonymousUser') ? principal : null
def user = currUser?.username
if (user == null && !controllerName.equals("logout")) {
if (!request.xhr) {
println "not ajax call"
redirect (url:ApplicationHolder.application.metadata['security.filters.url'])
println "after redirect ........"
return false
} else {
println "ajax call ......"
redirect (url:ApplicationHolder.application.metadata['security.filters.url'])
return false
}
}
}
}
}
}
Thanks
Sudhakar