Skip to content

Commit

Permalink
Added logout helper
Browse files Browse the repository at this point in the history
  • Loading branch information
cr4yfish committed Jul 8, 2023
1 parent 5b16539 commit d32938e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions utils/authFunctions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { deleteCookie } from "cookies-next";
import { GetSiteResponse } from "lemmy-js-client";

export const handleLogout = async ({ session, setSession, router } : { session: any, setSession: Function, router: any }) => {

// delete the cookie
deleteCookie("jwt");

// delete sessionStorage
sessionStorage.removeItem("jwt");

// set session to empty
setSession({ ...session, user: {} as GetSiteResponse, jwt: "" });

// redirect to home
router.push("/");
}

0 comments on commit d32938e

Please sign in to comment.