diff --git a/src/components/catalog/catalog-element.riot b/src/components/catalog/catalog-element.riot index e3de4cc..cdf151a 100644 --- a/src/components/catalog/catalog-element.riot +++ b/src/components/catalog/catalog-element.riot @@ -111,7 +111,7 @@ along with this program. If not, see . onAuthentication: props.onAuthentication, withCredentials: props.isRegistrySecured, }); - oReq.addEventListener('load', function () { + oReq.addEventListener('loadend', function () { if (this.status === 200) { const nbTags = (JSON.parse(this.responseText).tags || []).length; self.update({ nbTags }); diff --git a/src/scripts/http.js b/src/scripts/http.js index d4919d9..58b4c32 100644 --- a/src/scripts/http.js +++ b/src/scripts/http.js @@ -54,9 +54,9 @@ export class Http { switch (e) { case 'loadend': { self.oReq.addEventListener('loadend', function () { - if (this.status === 401 && !this.withCredentials) { - const tokenAuth = - this.hasHeader('www-authenticate') && parseAuthenticateHeader(this.getResponseHeader('www-authenticate')); + const tokenAuth = + this.hasHeader('www-authenticate') && parseAuthenticateHeader(this.getResponseHeader('www-authenticate')); + if (this.status === 401 && (!this.withCredentials || tokenAuth)) { self.onAuthentication(tokenAuth, (bearer) => { const req = new XMLHttpRequest(); req._url = self._url;