Skip to content

Commit

Permalink
Merge pull request #240 from appwrite/feat-dropdown-logout
Browse files Browse the repository at this point in the history
feat: add logout btn to dropdown
  • Loading branch information
TorstenDittmann authored Jan 30, 2023
2 parents 4f14c2d + c73f7f5 commit 666ee81
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib/layout/header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import { slide } from 'svelte/transition';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { sdkForConsole } from '$lib/stores/sdk';
import { goto } from '$app/navigation';
let showDropdown = false;
let droplistElement: HTMLDivElement;
Expand All @@ -32,6 +34,12 @@
}
}
async function logout() {
await sdkForConsole.account.deleteSession('current');
trackEvent('submit_account_logout');
await goto(`${base}/login`);
}
function onBlur(event: MouseEvent) {
if (
showDropdown &&
Expand Down Expand Up @@ -134,6 +142,14 @@
on:click={() => (showDropdown = false)}>
Your Account
</DropListLink>
<DropListItem
icon="logout-right"
on:click={() => {
showDropdown = false;
logout();
}}>
Sign Out
</DropListItem>
</ul>
</section>
<section class="drop-section">
Expand Down

1 comment on commit 666ee81

@vercel
Copy link

@vercel vercel bot commented on 666ee81 Jan 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.