diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index 152f8a9..7e839e4 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -89,4 +89,18 @@ export class AccountHelper { if (currentAccount == null) throw new Error("Current account is null!"); return currentAccount; } + + /** + * Sign out current user + */ + static async signOut() { + try { + await serverRequest("accounts/sign_out"); + } catch (e) { + console.error(e); + } + + sessionStorage.removeItem(SESSION_STORAGE_TOKEN); + document.location.href = document.location.href + ""; + } } diff --git a/src/ui/routes/MainRoute.tsx b/src/ui/routes/MainRoute.tsx index 4cc67eb..0d93c4f 100644 --- a/src/ui/routes/MainRoute.tsx +++ b/src/ui/routes/MainRoute.tsx @@ -106,6 +106,11 @@ function Menu() { export function MainRoute() { const classes = useStyles(); + + const signOut = () => { + AccountHelper.signOut(); + }; + return ( {AccountHelper.currentAccount.email} - +