I am facing an issue with redirecting my website flow to the login page when a user clicks any link on the page after the session has expired (either due to timeout or manual logout from another window).
In an attempt to solve this, I inserted the following code snippet into my main.gsp file (included in every gsp):
<script>
$.ajaxSetup({
statusCode: {
401: function(){
// Redirect the user to the login page.
location.href = "/gra/login/auth";
}
}
});
</script>
This solution was working fine initially, but after some recent changes to our application such as Oracle migration, UI updates, and implementation of a Spring security plugin, it seems that instead of forwarding the entire page to the login page, only the content in the target container gets refreshed. This means that when a user clicks a link after the session timeout, the logout page is loaded within that specific container.
Previously, the system would automatically direct the user to the login page without any issues. How can I modify this to ensure a global page redirection?
Update: Upon inspecting with Firebug, I discovered that clicking a link post-session timeout now triggers a 302 response code (moved temporarily) instead of the expected 401 error. What steps should I take to address this discrepancy?