Skip to content

Commit b7fc11b

Browse files
committed
fix(auth): run user sync in hooks immediately and fix auth methods path
- User create/update hooks now call runEnsureNow() so Payload has the user before the response (fixes magic-link redirect seeing missing user). - Change auth methods endpoint from /auth/methods to /methods so the full path is /api/auth/methods; update BetterAuthLoginServer fetch URL. - Reconcile queue: extract runEnsure(), add public runEnsureNow() for use from hooks while still enqueueing for idempotent retry. - E2E: add dev:auth:test script and second Playwright webServer so tests run with both app and auth server; run build before dev:build in e2e. - dev: point next-env.d.ts at .next/types/routes.d.ts.
1 parent ab7dc21 commit b7fc11b

File tree

13 files changed

+93
-55
lines changed

13 files changed

+93
-55
lines changed

dev/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/dev/types/routes.d.ts";
3+
import "./.next/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

dist/better-auth/plugin.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/better-auth/plugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/better-auth/reconcile-queue.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,20 @@ export declare class Queue {
4545
private clearFullReconcileTasks;
4646
private enqueue;
4747
private listBAUsersPage;
48+
private runEnsure;
4849
private runTask;
4950
private scheduleNextReconcile;
5051
/** Paginated approach: process users page by page to reduce memory usage */
5152
private seedFullReconcilePaginated;
5253
private tick;
5354
enqueueDelete(baId: string, priority?: boolean, source?: TaskSource, reconcileId?: string): void;
5455
enqueueEnsure(user: BAUser, priority?: boolean, source?: TaskSource, reconcileId?: string): void;
56+
/**
57+
* Run ensure (sync user to Payload) immediately without waiting for the queue tick.
58+
* Used from database hooks so that e.g. magic-link redirect sees the user in Payload
59+
* before the response is sent. The task remains enqueued for idempotent retry.
60+
*/
61+
runEnsureNow(user: BAUser): Promise<void>;
5562
/** Seed tasks by comparing users page by page (Better-Auth → Payload). */
5663
seedFullReconcile(): Promise<void>;
5764
start({ reconcileEveryMs, tickMs }?: {

dist/better-auth/reconcile-queue.js

Lines changed: 23 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/better-auth/reconcile-queue.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/BetterAuthLoginServer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/BetterAuthLoginServer.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)