From 5ee0ed401f72ddd822e0093d19a9779cf2039a64 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 7 Jan 2015 17:45:01 -0500 Subject: [PATCH] fixed ajaxify's redirecting to external URLs.. well fixed redirecting in general --- public/src/ajaxify.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 32f5a8bfbd..4896c58195 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -28,15 +28,19 @@ $(document).ready(function() { textStatus = err.textStatus; if (data) { - if (data.status === 403 || data.status === 404 || data.status === 500) { + var status = parseInt(data.status, 10); + + if (status === 403 || status === 404 || status === 500) { $('#footer, #content').removeClass('hide').addClass('ajaxifying'); - return renderTemplate(url, data.status.toString(), data.responseJSON, (new Date()).getTime(), callback); - } else if (data.status === 401) { + return renderTemplate(url, status.toString(), data.responseJSON, (new Date()).getTime(), callback); + } else if (status === 401) { app.alertError('[[global:please_log_in]]'); app.previousUrl = url; return ajaxify.go('login'); - } else if (data.status === 302) { - return ajaxify.go(data.responseJSON.slice(1), callback, quiet); + } else if (status === 302) { + if (!ajaxify.go(data.responseJSON.path, callback, quiet)) { + window.location.href = data.responseJSON.path; + } } } else if (textStatus !== "abort") { app.alertError(data.responseJSON.error);