mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-20 06:08:35 +02:00
Simple hack to catch redirections after an ajax request. It is not a clean and perfect solution but it should address most cases.
fix #181
This commit is contained in:
@@ -206,6 +206,9 @@ var AnchorNavigation = new Class({
|
||||
new Request.JSON({
|
||||
url: query,
|
||||
noCache : true,
|
||||
onComplete: function() {
|
||||
ajax_login_redirect();
|
||||
},
|
||||
onSuccess: function(resp) {
|
||||
var callback = ($defined(resp.callback)) ? resp.callback : "default";
|
||||
this.callbacks[callback](resp);
|
||||
|
||||
+1
-1
@@ -229,4 +229,4 @@ saveparams = function(id, message) {
|
||||
}
|
||||
}).send();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Collection of functions that are accessible to every page.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Simple function that redirect ajax requests to the login page if
|
||||
* the status code received with a response is equal to 278.
|
||||
*/
|
||||
function ajax_login_redirect() {
|
||||
if (this.status != 278) {
|
||||
return;
|
||||
}
|
||||
var params = "?next=" + window.location.pathname;
|
||||
|
||||
window.location.href =
|
||||
this.xhr.getResponseHeader("Location").replace(/\?.*$/, params);
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple wrapper around Request.JSON. We just ensure that
|
||||
* redirections are correctly catched. (on session timeout for
|
||||
* example)
|
||||
*/
|
||||
Request.JSON.mdb = new Class({
|
||||
Extends: Request.JSON,
|
||||
|
||||
options: {
|
||||
onComplete: ajax_login_redirect
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user