Skip to content

Commit 3414d7b

Browse files
committed
feat(token-auth): check the presence of www-authenticate header before the status code
1 parent cd99f6e commit 3414d7b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/components/catalog/catalog-element.riot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
111111
onAuthentication: props.onAuthentication,
112112
withCredentials: props.isRegistrySecured,
113113
});
114-
oReq.addEventListener('load', function () {
114+
oReq.addEventListener('loadend', function () {
115115
if (this.status === 200) {
116116
const nbTags = (JSON.parse(this.responseText).tags || []).length;
117117
self.update({ nbTags });

src/scripts/http.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ export class Http {
5454
switch (e) {
5555
case 'loadend': {
5656
self.oReq.addEventListener('loadend', function () {
57-
if (this.status === 401 && !this.withCredentials) {
58-
const tokenAuth =
59-
this.hasHeader('www-authenticate') && parseAuthenticateHeader(this.getResponseHeader('www-authenticate'));
57+
const tokenAuth =
58+
this.hasHeader('www-authenticate') && parseAuthenticateHeader(this.getResponseHeader('www-authenticate'));
59+
if (this.status === 401 && (!this.withCredentials || tokenAuth)) {
6060
self.onAuthentication(tokenAuth, (bearer) => {
6161
const req = new XMLHttpRequest();
6262
req._url = self._url;

0 commit comments

Comments
 (0)