Security Filter issue

19 views
Skip to first unread message

Sudhakar Vaddi

unread,
Jun 21, 2010, 1:52:47 AM6/21/10
to ig...@googlegroups.com
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

Himanshu Seth

unread,
Jun 21, 2010, 4:57:58 AM6/21/10
to ig...@googlegroups.com

Sudhakar Vaddi

unread,
Jun 21, 2010, 6:24:10 AM6/21/10
to ig...@googlegroups.com
Thank u.

It doesnt help. Any other suggestions pls ..

Thanks
Sudhakar
Reply all
Reply to author
Forward
0 new messages