Skip to content

Commit b056945

Browse files
committed
fix: add missing return types to component methods
1 parent a8013ff commit b056945

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/client/index.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ export class BetterAuth<UserId extends string = string> {
151151
if (!identity) {
152152
return null;
153153
}
154-
const doc = await ctx.runQuery(this.component.lib.findOne, {
154+
const doc:
155+
| null
156+
| (Infer<typeof schema.tables.user.validator> & {
157+
_id: string;
158+
_creationTime: number;
159+
}) = await ctx.runQuery(this.component.lib.findOne, {
155160
model: "user",
156161
where: [
157162
{
@@ -167,8 +172,7 @@ export class BetterAuth<UserId extends string = string> {
167172
if (!("emailVerified" in doc)) {
168173
throw new Error("invalid user");
169174
}
170-
const { id: _id, ...user } = doc;
171-
return user;
175+
return omit(doc, ["_id", "_creationTime"]);
172176
}
173177

174178
async getIdTokenCookieName(
@@ -201,10 +205,19 @@ export class BetterAuth<UserId extends string = string> {
201205
ctx: GenericQueryCtx<GenericDataModel>,
202206
username: string
203207
) {
204-
return ctx.runQuery(this.component.lib.findOne, {
208+
const user:
209+
| null
210+
| (Infer<typeof schema.tables.user.validator> & {
211+
_id: string;
212+
_creationTime: number;
213+
}) = await ctx.runQuery(this.component.lib.findOne, {
205214
model: "user",
206215
where: [{ field: "username", value: username }],
207216
});
217+
if (!user) {
218+
return null;
219+
}
220+
return omit(user, ["_id", "_creationTime"]);
208221
}
209222

210223
createAuthFunctions<DataModel extends GenericDataModel>(opts: {

0 commit comments

Comments
 (0)