From f12aff0718be30accd8da54b33ba10d70945a9ae Mon Sep 17 00:00:00 2001 From: Emre Ozdemir Date: Sat, 16 Nov 2024 00:46:44 -0800 Subject: [PATCH] fix: pass all the options when deleting cookies (#551) --- packages/better-auth/src/cookies/index.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/better-auth/src/cookies/index.ts b/packages/better-auth/src/cookies/index.ts index e4d7a8b41c..96ea25ca06 100644 --- a/packages/better-auth/src/cookies/index.ts +++ b/packages/better-auth/src/cookies/index.ts @@ -1,13 +1,13 @@ import type { CookieOptions } from "better-call"; import { TimeSpan } from "oslo"; -import type { BetterAuthOptions } from "../types/options"; -import type { GenericEndpointContext } from "../types/context"; -import { BetterAuthError } from "../error"; -import { isProduction } from "../utils/env"; -import type { Session, User } from "../types"; +import { base64url } from "oslo/encoding"; import { hmac } from "../crypto/hash"; -import { base64, base64url } from "oslo/encoding"; +import { BetterAuthError } from "../error"; +import type { Session, User } from "../types"; +import type { GenericEndpointContext } from "../types/context"; +import type { BetterAuthOptions } from "../types/options"; import { getDate } from "../utils/date"; +import { isProduction } from "../utils/env"; export function createCookieGetter(options: BetterAuthOptions) { const secure = @@ -166,12 +166,15 @@ export async function setSessionCookie( export function deleteSessionCookie(ctx: GenericEndpointContext) { ctx.setCookie(ctx.context.authCookies.sessionToken.name, "", { + ...ctx.context.authCookies.sessionToken.options, maxAge: 0, }); ctx.setCookie(ctx.context.authCookies.sessionData.name, "", { + ...ctx.context.authCookies.sessionData.options, maxAge: 0, }); ctx.setCookie(ctx.context.authCookies.dontRememberToken.name, "", { + ...ctx.context.authCookies.dontRememberToken.options, maxAge: 0, }); }