Skip to content

Commit

Permalink
feat(token-auth): check the presence of www-authenticate header bef…
Browse files Browse the repository at this point in the history
…ore the status code
  • Loading branch information
Joxit committed Aug 2, 2023
1 parent cd99f6e commit 3414d7b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/catalog/catalog-element.riot
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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 });
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3414d7b

Please sign in to comment.