|
|
|
|
@ -8,21 +8,47 @@
@@ -8,21 +8,47 @@
|
|
|
|
|
|
|
|
|
|
let services = $state([]); |
|
|
|
|
|
|
|
|
|
onMount(async () => { |
|
|
|
|
async function loadButtons(){ |
|
|
|
|
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/oidc/buttons`; |
|
|
|
|
const resp = await fetch(url,{credentials:'include'}); |
|
|
|
|
if (resp.ok){ |
|
|
|
|
const json = await resp.json(); |
|
|
|
|
while (services.length) services.pop(); |
|
|
|
|
for (let service of json) services.push(service); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMount(loadButtons); |
|
|
|
|
|
|
|
|
|
async function connect(service){ |
|
|
|
|
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/oidc/redirect/${service}`; |
|
|
|
|
const resp = await fetch(url,{credentials:'include'}); |
|
|
|
|
if (resp.ok){ |
|
|
|
|
var json = await resp.json(); |
|
|
|
|
if (json.authorization_endpoint) { |
|
|
|
|
var endpoint = json.authorization_endpoint; |
|
|
|
|
delete json.authorization_endpoint; |
|
|
|
|
location.href = endpoint + '?' + new URLSearchParams(json); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function drop(service){ |
|
|
|
|
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/oidc/${service}`; |
|
|
|
|
const resp = await fetch(url,{ |
|
|
|
|
credentials: 'include', |
|
|
|
|
method: 'DELETE' |
|
|
|
|
}); |
|
|
|
|
if (resp.ok) loadButtons(); |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<fieldset tabindex="0"> |
|
|
|
|
<legend> |
|
|
|
|
{t('user.login_services')} |
|
|
|
|
<button>{t('user.add_login_service')}</button> |
|
|
|
|
{#if user.permissions.includes('MANAGE_LOGIN_SERVICES')} |
|
|
|
|
<button onclick={() => router.navigate('/user/oidc/add')}>{t('user.add_login_service')}</button> |
|
|
|
|
{/if} |
|
|
|
|
</legend> |
|
|
|
|
<table> |
|
|
|
|
<thead> |
|
|
|
|
@ -36,10 +62,10 @@
@@ -36,10 +62,10 @@
|
|
|
|
|
<tr> |
|
|
|
|
<td>{service}</td> |
|
|
|
|
<td> |
|
|
|
|
<button>{t('user.connect_service')}</button> |
|
|
|
|
<button onclick={() => connect(service)}>{t('user.connect_service')}</button> |
|
|
|
|
{#if user.permissions.includes('MANAGE_LOGIN_SERVICES')} |
|
|
|
|
<button onclick={() => router.navigate(`/user/oidc/${service}`)}>{t('user.edit')}</button> |
|
|
|
|
<button>{t('user.delete')}</button> |
|
|
|
|
<button onclick={() => router.navigate(`/user/oidc/edit/${service}`)}>{t('user.edit')}</button> |
|
|
|
|
<button onclick={() => drop(service)}>{t('user.delete')}</button> |
|
|
|
|
{/if} |
|
|
|
|
</td> |
|
|
|
|
</tr> |
|
|
|
|
|