Skip to content

Commit a538bd9

Browse files
committed
test(platform-live): sign out before signing in as another person
Better Auth serves its session_data cookie cache without matching it to the session token, so a check that signed in a second person kept the first one's cached session: the platform-admin and nothing-deleted people saw the organization administrator's pages.
1 parent 7de8deb commit a538bd9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎apps/sim/platform/checks/live/session.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,14 @@ export async function seedSession(email: string): Promise<SeededSession> {
9696
}
9797
}
9898

99-
/** Opens `target` as `email`, on a session seeded for this call, and returns that session. */
99+
/**
100+
* Opens `target` as `email`, on a session seeded for this call, and returns that session. Signs out
101+
* first, as a person switching accounts does: Better Auth serves its cached session cookie without
102+
* matching it to the token, so a check signing in again would otherwise stay the earlier person.
103+
*/
100104
export async function signIn(page: Page, email: string, target: string): Promise<SeededSession> {
101105
const session = await seedSession(email)
106+
await page.context().clearCookies({ name: /^better-auth\./ })
102107
await page.context().addCookies([session.cookie])
103108
await page.goto(target)
104109
return session

0 commit comments

Comments
 (0)