Changeset View
Changeset View
Standalone View
Standalone View
assets/src/bundles/auth/index.js
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | csrfPost(Urls.oidc_get_bearer_token(), {}, JSON.stringify(postData)) | ||||
.then(handleFetchError) | .then(handleFetchError) | ||||
.then(response => response.text()) | .then(response => response.text()) | ||||
.then(token => { | .then(token => { | ||||
const tokenHtml = | const tokenHtml = | ||||
`<p>Below is your token.</p> | `<p>Below is your token.</p> | ||||
<pre id="swh-bearer-token" class="mt-3">${token}</pre>`; | <pre id="swh-bearer-token" class="mt-3">${token}</pre>`; | ||||
swh.webapp.showModalHtml('Display bearer token', tokenHtml); | swh.webapp.showModalHtml('Display bearer token', tokenHtml); | ||||
}) | }) | ||||
.catch(() => { | .catch(response => { | ||||
swh.webapp.showModalHtml('Display bearer token', errorMessage('Internal server error.')); | response.text().then(responseText => { | ||||
let errorMsg = 'Internal server error.'; | |||||
if (response.status === 400) { | |||||
errorMsg = responseText; | |||||
} | |||||
swh.webapp.showModalHtml('Display bearer token', errorMessage(errorMsg)); | |||||
}); | |||||
}); | }); | ||||
} | } | ||||
function revokeTokens(tokenIds) { | function revokeTokens(tokenIds) { | ||||
const postData = { | const postData = { | ||||
token_ids: tokenIds | token_ids: tokenIds | ||||
}; | }; | ||||
csrfPost(Urls.oidc_revoke_bearer_tokens(), {}, JSON.stringify(postData)) | csrfPost(Urls.oidc_revoke_bearer_tokens(), {}, JSON.stringify(postData)) | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |