This repository has been archived on 2023-08-28. You can view files and clone it, but cannot push or open issues/pull-requests.
memejoin-svelte/src/routes/auth/+page.svelte

29 lines
727 B
Svelte

<script>
import { onMount } from 'svelte';
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import { member, intros } from '../../store.ts';
const code = $page.url.searchParams.get('code');
let loginFailed = false;
onMount(async () => {
const response = await fetch(`http://localhost:7756/auth?code=${code}`);
const body = await response.json();
if (!response.ok) {
loginFailed = true
} else {
await member.login(body.token);
await intros.fetchIntros($member.guilds);
goto('/')
}
});
</script>
{#if loginFailed}
<p style='color: red'>Login failed</p>
{/if}