Quantcast
Channel: Rubythings
Viewing all articles
Browse latest Browse all 9

Ajax redirects with devise

0
0
When devise times out, the user should be forced to log in again. This works fine when the user attempts to access my app using an html request, but ajax requests were bringing up the http_authentication pop-up box from the browser. Googling around suggested various ways of dealing with this, all of which seemed to involve a lot of unnecessary work. Just putting
// Set up a global AJAX error handler to handle the 401
// unauthorized responses. If a 401 status code comes back,
// the user is no longer logged-into the system and can not
// use it properly.
$.ajaxSetup({
statusCode: {
401: function(){

// Redirect the to the login page.
location.href = "/";;

}
}
});
in the application.js file solved the problem.

Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images