mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
77 lines
2.4 KiB
Plaintext
77 lines
2.4 KiB
Plaintext
<h1>Create client credentials token</h1>
|
|
<form method="post" id="mainForm">
|
|
<p class="error" id="error"></p>
|
|
|
|
<fieldset>
|
|
<p>Choose a name and which WebID to associate with the token</p>
|
|
<ol>
|
|
<li>
|
|
<label for="name">Name</label>
|
|
<input id="name" type="text" name="name" autofocus>
|
|
</li>
|
|
</ol>
|
|
<ol id="webIdList">
|
|
</ol>
|
|
</fieldset>
|
|
|
|
<ul class="actions">
|
|
<li><button type="submit" name="submit">Create token</button></li>
|
|
<li><button type="button" id="account-link">Back</button></li>
|
|
</ul>
|
|
</form>
|
|
<div class="hidden" id="no-webId">
|
|
<p class="error">There are no WebIDs linked to this account.</p>
|
|
<p class="actions"><button type="button" id="error-account-link">Back</button></p>
|
|
</div>
|
|
<div class="hidden" id="response">
|
|
<p>
|
|
Make sure to store the secret somewhere as there is no way to retrieve it afterwards!
|
|
</p>
|
|
<p>
|
|
Token identifier: <strong id="token-id"></strong>
|
|
</p>
|
|
<p>
|
|
Token secret: <strong style="word-wrap:break-word;" id="token-secret"></strong>
|
|
</p>
|
|
|
|
<p class="actions"><button type="button" id="response-account-link">Back</button></p>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
(async() => {
|
|
const controls = await fetchControls('<%= idpIndex %>');
|
|
const { webIdLinks } = await fetchJson(controls.account.webId, '<%= idpIndex %>');
|
|
|
|
setRedirectClick('account-link', controls.html.account.account);
|
|
setRedirectClick('error-account-link', controls.html.account.account);
|
|
setRedirectClick('response-account-link', controls.html.account.account);
|
|
|
|
const webIds = Object.keys(webIdLinks);
|
|
if (webIds.length === 0) {
|
|
setVisibility('no-webId', true);
|
|
setVisibility('mainForm', false);
|
|
return;
|
|
}
|
|
|
|
const { webIdList } = getElements('webIdList');
|
|
for (const webId of webIds) {
|
|
webIdList.insertAdjacentHTML('beforeend', `
|
|
<li class="radio">
|
|
<label for="${webId}">
|
|
<input id="${webId}" type="radio" name="webId" value="${webId}" ${webIds.length === 1 ? 'checked' : ''}>
|
|
${webId}
|
|
</label>
|
|
</li>`);
|
|
}
|
|
|
|
addPostListener(async() => {
|
|
const { id, secret } = await postJsonForm(controls.account.clientCredentials);
|
|
updateElement('token-id', id, { innerText: true });
|
|
updateElement('token-secret', secret, { innerText: true });
|
|
setVisibility('response', true);
|
|
setVisibility('mainForm', false);
|
|
});
|
|
})();
|
|
</script>
|