@@ -151,7 +151,12 @@ export class BetterAuth<UserId extends string = string> {
151
151
if ( ! identity ) {
152
152
return null ;
153
153
}
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 , {
155
160
model : "user" ,
156
161
where : [
157
162
{
@@ -167,8 +172,7 @@ export class BetterAuth<UserId extends string = string> {
167
172
if ( ! ( "emailVerified" in doc ) ) {
168
173
throw new Error ( "invalid user" ) ;
169
174
}
170
- const { id : _id , ...user } = doc ;
171
- return user ;
175
+ return omit ( doc , [ "_id" , "_creationTime" ] ) ;
172
176
}
173
177
174
178
async getIdTokenCookieName (
@@ -201,10 +205,19 @@ export class BetterAuth<UserId extends string = string> {
201
205
ctx : GenericQueryCtx < GenericDataModel > ,
202
206
username : string
203
207
) {
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 , {
205
214
model : "user" ,
206
215
where : [ { field : "username" , value : username } ] ,
207
216
} ) ;
217
+ if ( ! user ) {
218
+ return null ;
219
+ }
220
+ return omit ( user , [ "_id" , "_creationTime" ] ) ;
208
221
}
209
222
210
223
createAuthFunctions < DataModel extends GenericDataModel > ( opts : {
0 commit comments