3 changed files with 51 additions and 79 deletions
@ -1,61 +0,0 @@
@@ -1,61 +0,0 @@
|
||||
<script> |
||||
import { onMount } from 'svelte'; |
||||
|
||||
import { api } from '../../urls.svelte.js'; |
||||
import { t } from '../../translations.svelte.js'; |
||||
import { user } from '../../user.svelte.js'; |
||||
|
||||
let connections = $state([]); |
||||
|
||||
async function loadConnections(){ |
||||
const url = api('user/oidc/connected'); |
||||
const resp = await fetch(url,{credentials:'include'}); |
||||
if (resp.ok){ |
||||
const arr = await resp.json(); |
||||
while (connections.length) connections.pop(); |
||||
for (let entry of arr) connections.push(entry); |
||||
} |
||||
} |
||||
|
||||
onMount(loadConnections); |
||||
|
||||
async function unlink(connection){ |
||||
const url = api('user/oidc/connected'); |
||||
const resp = await fetch(url,{ |
||||
method : 'DELETE', |
||||
credentials : 'include', |
||||
body : JSON.stringify(connection) |
||||
}); |
||||
if (resp.ok){ |
||||
loadConnections(); |
||||
} else { |
||||
alert('failed'); |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
{#if connections.length>0} |
||||
<fieldset tabindex="0"> |
||||
<legend>{t('connected_services')}</legend> |
||||
<table> |
||||
<thead> |
||||
<tr> |
||||
<th>{t('service')}</th> |
||||
<th>{t('foreign_id')}</th> |
||||
<th>{t('actions')}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{#each connections as connection,i} |
||||
<tr> |
||||
<td>{connection.service_id}</td> |
||||
<td>{connection.foreign_id}</td> |
||||
<td> |
||||
<button onclick={() => unlink(connection)}>{t('unlink')}</button> |
||||
</td> |
||||
</tr> |
||||
{/each} |
||||
</tbody> |
||||
</table> |
||||
</fieldset> |
||||
{/if} |
||||
Loading…
Reference in new issue