mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-25 00:22:43 -05:00
fix: log error when misconfigured (#7584)
This commit is contained in:
@@ -595,6 +595,7 @@ describe("base context creation", () => {
|
||||
});
|
||||
|
||||
it("should return false when generateId is false", async () => {
|
||||
const fn = vi.spyOn(console, "error").mockImplementation(vi.fn());
|
||||
const res = await initBase({
|
||||
advanced: {
|
||||
database: {
|
||||
@@ -602,6 +603,10 @@ describe("base context creation", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(fn).toHaveBeenCalled();
|
||||
const regex = /Misconfiguration detected/;
|
||||
expect(fn).toHaveBeenCalledWith(expect.stringMatching(regex));
|
||||
fn.mockRestore();
|
||||
const id = res.generateId({ model: "user" });
|
||||
expect(id).toBe(false);
|
||||
});
|
||||
|
||||
@@ -112,6 +112,18 @@ export async function createAuthContext(
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
adapter.id === "memory" &&
|
||||
options.advanced?.database?.generateId === false
|
||||
) {
|
||||
logger.error(
|
||||
`[better-auth] Misconfiguration detected.
|
||||
You are using the memory DB with generateId: false.
|
||||
This will cause no id to be generated for any model.
|
||||
Most of the features of Better Auth will not work correctly.`,
|
||||
);
|
||||
}
|
||||
|
||||
const secret =
|
||||
options.secret ||
|
||||
env.BETTER_AUTH_SECRET ||
|
||||
|
||||
Reference in New Issue
Block a user