This commit is contained in:
@@ -4,14 +4,20 @@ import {
|
||||
ACCESS_TOKEN,
|
||||
AUTH_USER_ID,
|
||||
CLAIM_NAME,
|
||||
COOKIE_DOMAIN,
|
||||
REFRESH_TOKEN,
|
||||
} from "@/shared/config";
|
||||
|
||||
const cookieOptions = {
|
||||
path: "/",
|
||||
domain: COOKIE_DOMAIN,
|
||||
};
|
||||
|
||||
export async function POST() {
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.delete(ACCESS_TOKEN);
|
||||
cookieStore.delete(REFRESH_TOKEN);
|
||||
cookieStore.delete(AUTH_USER_ID);
|
||||
cookieStore.delete(CLAIM_NAME);
|
||||
cookieStore.delete({ name: ACCESS_TOKEN, ...cookieOptions });
|
||||
cookieStore.delete({ name: REFRESH_TOKEN, ...cookieOptions });
|
||||
cookieStore.delete({ name: AUTH_USER_ID, ...cookieOptions });
|
||||
cookieStore.delete({ name: CLAIM_NAME, ...cookieOptions });
|
||||
return NextResponse.json({ message: "Logged out" }, { status: 200 });
|
||||
}
|
||||
|
||||
@@ -9,10 +9,7 @@ export function createTokenManager(config: AuthConfig) {
|
||||
|
||||
if (config.cookieDomain) return config.cookieDomain;
|
||||
|
||||
const { hostname } = window.location;
|
||||
if (hostname === "localhost" || hostname === "127.0.0.1") return undefined;
|
||||
|
||||
return hostname;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -65,7 +62,9 @@ export function createTokenManager(config: AuthConfig) {
|
||||
},
|
||||
|
||||
getRefreshToken(): string | undefined {
|
||||
return config.refreshToken ? this.getToken(config.refreshToken) : undefined;
|
||||
return config.refreshToken
|
||||
? this.getToken(config.refreshToken)
|
||||
: undefined;
|
||||
},
|
||||
|
||||
getUserId(): string | undefined {
|
||||
|
||||
Reference in New Issue
Block a user