Skip to content

Commit

Permalink
Fixed Logout is buggy #159
Browse files Browse the repository at this point in the history
  • Loading branch information
harshjohar committed Jan 31, 2024
1 parent 1aeb67f commit d08979b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Cookies from "universal-cookie";
import { signOut } from "next-auth/react";
import { NextRouter } from "next/router";
import { Session } from "next-auth";
import { Common } from "../constants/common";

const logout = async (router: NextRouter, session: Session | null) => {
try {
Expand All @@ -10,12 +11,13 @@ const logout = async (router: NextRouter, session: Session | null) => {
let data;
if (session) {
data = session;
signOut();
await signOut();
} else {
data = cookies.get("session-token");
}
cookies.remove("redirectPath");
cookies.remove("session-token");
localStorage.removeItem(Common.AUTHORIZATION);

router.push('/');
return {
Expand Down
1 change: 0 additions & 1 deletion pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const authOptions = (req: NextApiRequest, res: NextApiResponse) => {
url: "/v1/users",
token: cookies.get("session-token").token,
});
console.log(backendRes);
return session;
},

Expand Down

0 comments on commit d08979b

Please sign in to comment.