Skip to content

Commit d08979b

Browse files
committed
Fixed Logout is buggy #159
1 parent 1aeb67f commit d08979b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/logout.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Cookies from "universal-cookie";
22
import { signOut } from "next-auth/react";
33
import { NextRouter } from "next/router";
44
import { Session } from "next-auth";
5+
import { Common } from "../constants/common";
56

67
const logout = async (router: NextRouter, session: Session | null) => {
78
try {
@@ -10,12 +11,13 @@ const logout = async (router: NextRouter, session: Session | null) => {
1011
let data;
1112
if (session) {
1213
data = session;
13-
signOut();
14+
await signOut();
1415
} else {
1516
data = cookies.get("session-token");
1617
}
1718
cookies.remove("redirectPath");
1819
cookies.remove("session-token");
20+
localStorage.removeItem(Common.AUTHORIZATION);
1921

2022
router.push('/');
2123
return {

pages/api/auth/[...nextauth].ts

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const authOptions = (req: NextApiRequest, res: NextApiResponse) => {
2121
url: "/v1/users",
2222
token: cookies.get("session-token").token,
2323
});
24-
console.log(backendRes);
2524
return session;
2625
},
2726

0 commit comments

Comments
 (0)