code cleanup

This commit is contained in:
2025-07-30 15:35:19 +02:00
parent 631a527a5d
commit fccec9865a
27 changed files with 442 additions and 428 deletions

View File

@@ -1,24 +1,26 @@
<script>
import { onMount } from 'svelte';
import { t } from '../../translations.svelte.js';
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { checkUser } from '../../user.svelte.js';
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
import { checkUser } from '../../user.svelte.js';
const router = useTinyRouter();
let message = $state(t('processing_code'));
let message = $state(t('processing_code'));
onMount(async () => {
async function process(){
let params = new URLSearchParams(location.search);
if (params.get('code')){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/oidc/token`;
const url = api('user/oidc/token');
const resp = await fetch(url,{
method : 'POST',
body: JSON.stringify(Object.fromEntries(params)),
credentials: 'include'
method : 'POST',
body : JSON.stringify(Object.fromEntries(params)),
credentials : 'include'
});
if (resp.ok){
let json = await resp.json();
let json = await resp.json();
const redirect = json.redirect ? json.redirect : '/user';
checkUser();
router.navigate(redirect);
@@ -27,7 +29,9 @@
if (!message) message = t(resp);
}
}
});
}
onMount(process);
</script>
{message}