cone
cone3mo ago

BetterAuth User Type Safety

Any idea why the user returned from this function is of type "any"? Shouldn't it be typed according to the better auth user schema? async getAuthUser(ctx: RunQueryCtx & { auth: ConvexAuth }) { const identity = await ctx.auth.getUserIdentity(); if (!identity) { return null; } const doc = await ctx.runQuery(this.component.lib.findOne, { model: "user", where: [ { field: "userId", value: identity.subject, }, ], }); if (!doc) { return null; } // Type narrowing if (!("emailVerified" in doc)) { throw new Error("invalid user"); } const { id: _id, ...user } = doc; return user; }
2 Replies
Sean Aguinaga
Sean Aguinaga3mo ago
Yeahhh me either
erquhart
erquhart3mo ago
This is fixed in the latest release.

Did you find this page helpful?