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/Login.svelte

27 lines
823 B
Svelte

<script>
import { onMount } from 'svelte';
import { member, intros } from './store.ts';
const authorizeUri = "https://discord.com/api/oauth2/authorize?client_id=577634620728934400&redirect_uri=http%3A%2F%2Flocalhost%3A5173%2Fauth&response_type=code&scope=identify%20guilds%20guilds.members.read";
onMount(async () => {
const token = window.localStorage.getItem('token');
if (!!token) {
await member.pullData(token);
await intros.fetchIntros($member.guilds);
}
});
const login = async (username) => {
window.location = authorizeUri;
}
let loginPromise = null;
let enteredUsername = '';
</script>
<p style="color:red;">You need to login first</p>
<button on:click={() => loginPromise = login(enteredUsername)}>Login</button>