Created
July 26, 2021 15:22
-
-
Save robertohuertasm/cb7a49ab9c3da304aaea38077519a75a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { signOut as authSignOut } from 'sk-auth/client'; | |
import { session } from '$app/stores'; | |
// getting the user from the session store | |
$: user = $session.user; | |
function signIn() { | |
location.assign('/api/auth/signin/cognito?redirect=/'); | |
} | |
function signOut() { | |
authSignOut().then(session.set); | |
} | |
</script> | |
<svelte:head> | |
<title>SvelteKit - Cognito</title> | |
</svelte:head> | |
{#if !user} | |
<button on:click="{signIn}">Log In with Cognito</button> | |
{:else} | |
<h2>Welcome {user.email}!</h2> | |
<p>Your username is {user.username} and your email has been verified: {user.email_verified}</p> | |
<button on:click={signOut}>Log Out</button> | |
{/if} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment