forked from mirrors/pronouns.cc
feat: move log out button to settings
This commit is contained in:
parent
e3f3ac1d8d
commit
1e6eb66168
4 changed files with 22 additions and 20 deletions
|
@ -1,14 +0,0 @@
|
|||
<script lang="ts">
|
||||
import { goto } from "$app/navigation";
|
||||
import { userStore } from "$lib/store";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
onMount(() => {
|
||||
userStore.set(null);
|
||||
localStorage.removeItem("pronouns-token");
|
||||
localStorage.removeItem("pronouns-user");
|
||||
goto("/");
|
||||
});
|
||||
</script>
|
||||
|
||||
<h1>Log out</h1>
|
|
@ -1 +0,0 @@
|
|||
export const ssr = false;
|
|
@ -85,9 +85,6 @@
|
|||
<NavItem>
|
||||
<NavLink href="/settings">Settings</NavLink>
|
||||
</NavItem>
|
||||
<NavItem>
|
||||
<NavLink href="/auth/logout">Log out</NavLink>
|
||||
</NavItem>
|
||||
{:else}
|
||||
<NavItem>
|
||||
<NavLink href="/auth/login">Log in</NavLink>
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
<script lang="ts">
|
||||
import { page } from "$app/stores";
|
||||
import type { LayoutData } from "./$types";
|
||||
|
||||
import { ListGroup, ListGroupItem } from "sveltestrap";
|
||||
import { Button, ListGroup, ListGroupItem, Modal, ModalBody, ModalFooter } from "sveltestrap";
|
||||
import { userStore } from "$lib/store";
|
||||
import { goto } from "$app/navigation";
|
||||
|
||||
export let data: LayoutData;
|
||||
|
||||
let isOpen = false;
|
||||
const toggle = () => (isOpen = !isOpen);
|
||||
|
||||
const logOut = () => {
|
||||
userStore.set(null);
|
||||
localStorage.removeItem("pronouns-token");
|
||||
localStorage.removeItem("pronouns-user");
|
||||
toggle();
|
||||
goto("/");
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="grid">
|
||||
|
@ -39,10 +51,18 @@
|
|||
>
|
||||
Data export
|
||||
</ListGroupItem>
|
||||
<ListGroupItem tag="button" on:click={toggle}>Log out</ListGroupItem>
|
||||
</ListGroup>
|
||||
</div>
|
||||
<div class="col-md m-3">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
<Modal header="Log out" {isOpen} {toggle}>
|
||||
<ModalBody>Are you sure you want to log out?</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" on:click={logOut}>Log out</Button>
|
||||
<Button color="secondary" on:click={toggle}>Cancel</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue