Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent session refresh by ajax call (grails)

I have a Grails based web app which uses Spring Security to handle user logins etc. I have hit a bit of a block and am hoping the more experienced might be able to point me in the right direction for a solution.

The application has the concept of messages which can be sent from user to user to provide a instant messaging feature. There is a timed Ajax call that is present throughout the system which is used to alert the user of any new incoming messages.

My problem is that since I have implemented this, each time the ajax call is performed, of course the users session is being refreshed, therefore never timesout. So a manual 'log out' is the only way they can log out, whereas before expiry of a session would redirect them to the login page.

Does anyone know how I can still accomplish automatic logouts whilst still have the timer functioning?

I'm hoping I can set up some kind of filter with spring security, or perhaps there's an annotation I can use on the periodically called method to instruct it NOT to refresh the users session.

As always any help & comments are appreciated.

like image 435
David Brown Avatar asked Nov 18 '25 03:11

David Brown


1 Answers

Thanks to Long for pointing me in a different direction with his comment, I believe I have now a much better, more intuitive user friendly solution.

Rather than trying to change things on the backend, I am using a little jQuery script which is very easily configured and fits in perfect with my app which already uses jQuery and the jQuery UI.

After a specific period, a jQuery dialog pops up, modally dimming the background and informs the user due to inactivity they will soon be logged out. A progress bar is displayed which reduces until it is empty at which point if the user hasn't click my 'Continue Working' button, then I change the window location to the spring security logout controller URL, taking them back to the sign in page. It works beautifully and is very easy to configure.

The instructions can be found here : http://kenbrowning.blogspot.co.uk/2010/04/are-you-still-there.html

Kudos to Ken Browning for his library.

like image 179
David Brown Avatar answered Nov 19 '25 21:11

David Brown



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!