Fix occasional 'whoami.data is undefined' error in FreeIPA web UI

'Metadata' phase (Web UI initialization flow) doesn't wait "whoami" response.
It causes the error when on the next phase "whoami" data is undefined.
To avoid this "whoami" request now has flag async = false,
so init_metadata waits until it will be completed.

Ticket: https://pagure.io/freeipa/issue/7917

Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Serhii Tsymbaliuk 2019-05-13 14:39:03 +02:00
parent 6662e99e17
commit 6a9c20a87c
No known key found for this signature in database
GPG Key ID: 632C7F5C1BC85519

View File

@ -251,7 +251,10 @@ var IPA = function () {
on_success: function(data, text_status, xhr) {
that.whoami.metadata = data.result || data;
var wa_data = that.whoami.metadata;
// This AJAX request has no synchronization point,
// so we set async = false to make sure that init_metadata
// doesn't start before we get whoami response.
$.ajaxSetup({async: false});
rpc.command({
method: wa_data.details || wa_data.command,
args: wa_data.arguments,
@ -275,6 +278,8 @@ var IPA = function () {
}
}
}).execute();
// Restore AJAX options
$.ajaxSetup(that.ajax_options);
}
});
};