chore: delete session with hooks (#6792)

This commit is contained in:
Jonathan Samines
2025-12-16 05:11:30 +00:00
committed by github-actions[bot]
parent f32d2baf08
commit ca80899628
2 changed files with 19 additions and 11 deletions
@@ -1,8 +1,17 @@
import { describe, expect } from "vitest";
import { describe, expect, vi } from "vitest";
import { getTestInstance } from "../../test-utils/test-instance";
describe("sign-out", async (it) => {
const { signInWithTestUser, client } = await getTestInstance();
const afterSessionDeleted = vi.fn();
const { signInWithTestUser, client } = await getTestInstance({
databaseHooks: {
session: {
delete: {
after: afterSessionDeleted,
},
},
},
});
it("should sign out", async () => {
const { runWithUser } = await signInWithTestUser();
@@ -11,6 +20,8 @@ describe("sign-out", async (it) => {
expect(res.data).toMatchObject({
success: true,
});
expect(afterSessionDeleted).toHaveBeenCalled();
});
});
});
@@ -586,15 +586,12 @@ export const createInternalAdapter = (
return;
}
}
await (await getCurrentAdapter(adapter)).delete<Session>({
model: "session",
where: [
{
field: "token",
value: token,
},
],
});
await deleteWithHooks(
[{ field: "token", value: token }],
"session",
undefined,
);
},
deleteAccounts: async (userId: string) => {
await deleteManyWithHooks(