mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-19 23:53:17 -05:00
chore: delete session with hooks (#6792)
This commit is contained in:
committed by
github-actions[bot]
parent
f32d2baf08
commit
ca80899628
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user