From 327067117a18ebda4930560bf2fa5d9fd00092fd Mon Sep 17 00:00:00 2001 From: lmeyer Date: Thu, 19 Sep 2024 07:53:08 +0200 Subject: [PATCH] update user model --- packages/models/src/user/User/User.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/models/src/user/User/User.ts b/packages/models/src/user/User/User.ts index f312ca22..23117f21 100644 --- a/packages/models/src/user/User/User.ts +++ b/packages/models/src/user/User/User.ts @@ -1,10 +1,8 @@ -import { ReferenceModel } from "../../base/ReferenceModel.js"; import { type AsyncResourceVariant, provideReact, } from "../../lib/provideReact.js"; import { config } from "../../config/config.js"; -import { DataModel } from "../../base/DataModel.js"; import { classes } from "polytype"; import { UserAuthenticateMfaRequestData, @@ -27,6 +25,7 @@ import { UserVerifyRegistrationRequestData, } from "./types.js"; import assertObjectFound from "../../base/assertObjectFound.js"; +import { DataModel, ReferenceModel } from "../../base/index.js"; export class User extends ReferenceModel { public static ofId(id: string): User { @@ -36,7 +35,6 @@ export class User extends ReferenceModel { public static find = provideReact( async (id: string): Promise => { const data = await config.behaviors.user.find(id); - if (data !== undefined) { return new UserDetailed(data); } @@ -46,9 +44,7 @@ export class User extends ReferenceModel { public static get = provideReact( async (id: string): Promise => { const user = await this.find(id); - assertObjectFound(user, this, id); - return user; }, ); @@ -57,10 +53,16 @@ export class User extends ReferenceModel { return await this.get("self"); }); - public getDetailed = provideReact(() => - User.get(this.id), + public getDetailed = provideReact( + () => User.get(this.id), + [this.id], ) as AsyncResourceVariant; + public findDetailed = provideReact( + () => User.find(this.id), + [this.id], + ) as AsyncResourceVariant; + public getPasswordUpdatedAt = provideReact( async (): Promise<{ passwordUpdatedAt: string }> => { return await config.behaviors.user.getPasswordUpdatedAt();