Fixed error after login on IE

The IE does not resend the request body during negotiation, so after
after a successful authentication the server could not find the JSON
request to parse.

The Web UI has been modified to detect this error and resend the
initialization request.

Ticket #1540
This commit is contained in:
Endi S. Dewata
2011-08-03 15:26:54 -05:00
parent 8edd7ed998
commit c5ce14c83a
2 changed files with 63 additions and 14 deletions

View File

@@ -138,6 +138,7 @@ IPA.host_adder_dialog = function(spec)
that.on_error = function(xhr, text_status, error_thrown) that.on_error = function(xhr, text_status, error_thrown)
{ {
var ajax = this;
var command = that.command; var command = that.command;
var data = error_thrown.data; var data = error_thrown.data;
var dialog = null; var dialog = null;
@@ -152,7 +153,7 @@ IPA.host_adder_dialog = function(spec)
fqdn: that.get_field('fqdn').save() fqdn: that.get_field('fqdn').save()
} }
}; };
command.on_success(data, text_status, xhr); command.on_success.call(ajax, data, text_status, xhr);
} }
}); });
} else { } else {

View File

@@ -70,8 +70,35 @@ var IPA = ( function () {
var batch = IPA.batch_command({ var batch = IPA.batch_command({
name: 'ipa_init', name: 'ipa_init',
retry: false,
on_success: on_success, on_success: on_success,
on_error: on_error on_error: function(xhr, text_status, error_thrown) {
// On IE the request is missing after authentication,
// so the request needs to be resent.
if (error_thrown.name == 'IPA Error 909') {
batch.execute();
} else {
var ajax = this;
var dialog = IPA.error_dialog({
xhr: xhr,
text_status: text_status,
error_thrown: error_thrown,
command: batch
});
dialog.on_cancel = function() {
dialog.close();
if (on_error) {
on_error.call(ajax, xhr, text_status, error_thrown);
}
};
dialog.open();
}
}
}); });
batch.add_command(IPA.command({ batch.add_command(IPA.command({
@@ -243,12 +270,23 @@ IPA.command = function(spec) {
that.execute = function() { that.execute = function() {
function dialog_open(xhr, text_status, error_thrown) { function dialog_open(xhr, text_status, error_thrown) {
var ajax = this;
var dialog = IPA.error_dialog({ var dialog = IPA.error_dialog({
xhr: xhr, xhr: xhr,
text_status: text_status, text_status: text_status,
error_thrown: error_thrown, error_thrown: error_thrown,
command: that command: that
}); });
dialog.on_cancel = function() {
dialog.close();
if (that.on_error) {
that.on_error.call(ajax, xhr, text_status, error_thrown);
}
};
dialog.open(); dialog.open();
} }
@@ -399,6 +437,7 @@ IPA.batch_command = function (spec) {
method: that.method, method: that.method,
args: that.args, args: that.args,
options: that.options, options: that.options,
retry: that.retry,
on_success: function(data, text_status, xhr) { on_success: function(data, text_status, xhr) {
for (var i=0; i<that.commands.length; i++) { for (var i=0; i<that.commands.length; i++) {
@@ -406,8 +445,10 @@ IPA.batch_command = function (spec) {
var result = data.result.results[i]; var result = data.result.results[i];
if (!result) { if (!result) {
if (command.on_error) command.on_error( if (command.on_error) command.on_error.call(
xhr, text_status, this,
xhr,
text_status,
{ {
name: 'Internal Error '+xhr.status, name: 'Internal Error '+xhr.status,
message: result ? xhr.statusText : "Internal error" message: result ? xhr.statusText : "Internal error"
@@ -415,7 +456,8 @@ IPA.batch_command = function (spec) {
); );
} else if (result.error) { } else if (result.error) {
if (command.on_error) command.on_error( if (command.on_error) command.on_error.call(
this,
xhr, xhr,
text_status, text_status,
{ {
@@ -425,15 +467,15 @@ IPA.batch_command = function (spec) {
); );
} else { } else {
if (command.on_success) command.on_success(result, text_status, xhr); if (command.on_success) command.on_success.call(this, result, text_status, xhr);
} }
} }
if (that.on_success) that.on_success(data, text_status, xhr); if (that.on_success) that.on_success.call(this, data, text_status, xhr);
}, },
on_error: function(xhr, text_status, error_thrown) { on_error: function(xhr, text_status, error_thrown) {
// TODO: undefined behavior // TODO: undefined behavior
if (that.on_error) { if (that.on_error) {
that.on_error(xhr, text_status, error_thrown); that.on_error.call(this, xhr, text_status, error_thrown);
} }
} }
}).execute(); }).execute();
@@ -571,6 +613,7 @@ IPA.dirty_dialog = function(spec) {
}; };
IPA.error_dialog = function(spec) { IPA.error_dialog = function(spec) {
var that = IPA.dialog(spec); var that = IPA.dialog(spec);
var init = function() { var init = function() {
@@ -605,19 +648,24 @@ IPA.error_dialog = function(spec) {
var label = IPA.messages.buttons ? IPA.messages.buttons.retry : 'Retry'; var label = IPA.messages.buttons ? IPA.messages.buttons.retry : 'Retry';
that.add_button(label, function() { that.add_button(label, function() {
that.close(); that.on_retry();
that.command.execute();
}); });
label = IPA.messages.buttons ? IPA.messages.buttons.cancel : 'Cancel'; label = IPA.messages.buttons ? IPA.messages.buttons.cancel : 'Cancel';
that.add_button(label, function() { that.add_button(label, function() {
that.close(); that.on_cancel();
if (that.command.retry && that.command.on_error) {
that.command.on_error(that.xhr, that.text_status, that.error_thrown);
}
}); });
}; };
that.on_retry = function() {
that.close();
that.command.execute();
};
that.on_cancel = function() {
that.close();
};
init(); init();
that.create_buttons(); that.create_buttons();