Commit 82851d6d authored by Joshua Tauberer's avatar Joshua Tauberer

suppress "Something went wrong, sorry." when the management daemon's api key has changed

parent 2f952a79
...@@ -277,7 +277,7 @@ function ajax(options) { ...@@ -277,7 +277,7 @@ function ajax(options) {
if (!old_error) if (!old_error)
show_modal_error("Error", "Something went wrong, sorry.") show_modal_error("Error", "Something went wrong, sorry.")
else else
old_error(jqxhr.responseText); old_error(jqxhr.responseText, jqxhr);
}; };
is_ajax_loading = true; is_ajax_loading = true;
$.ajax(options); $.ajax(options);
...@@ -312,6 +312,11 @@ function api(url, method, data, callback, callback_error) { ...@@ -312,6 +312,11 @@ function api(url, method, data, callback, callback_error) {
return output; return output;
} }
function default_error(text, xhr) {
if (xhr.status != 403) // else handled below
show_modal_error("Error", "Something went wrong, sorry.")
}
ajax({ ajax({
url: "/admin" + url, url: "/admin" + url,
method: method, method: method,
...@@ -325,7 +330,7 @@ function api(url, method, data, callback, callback_error) { ...@@ -325,7 +330,7 @@ function api(url, method, data, callback, callback_error) {
'Basic ' + base64encode(api_credentials[0] + ':' + api_credentials[1])); 'Basic ' + base64encode(api_credentials[0] + ':' + api_credentials[1]));
}, },
success: callback, success: callback,
error: callback_error, error: callback_error || default_error,
statusCode: { statusCode: {
403: function(xhr) { 403: function(xhr) {
// Credentials are no longer valid. Try to login again. // Credentials are no longer valid. Try to login again.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment