Skip to content

Commit 05f8468

Browse files
committed
improved getUser/useUser efficiency
1 parent 2f2c250 commit 05f8468

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/stack/src/lib/stack-app.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,8 +1953,7 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
19531953
async getUser(id: string): Promise<ServerUser | null>;
19541954
async getUser(options?: string | GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | ServerUser | null> {
19551955
if (typeof options === "string") {
1956-
const allUsers = await this.listUsers();
1957-
return allUsers.find((u) => u.id === options) ?? null;
1956+
return await this.getServerUserById(options);
19581957
} else {
19591958
// TODO this code is duplicated from the client app; fix that
19601959
this._ensurePersistentTokenStore(options?.tokenStore);
@@ -1996,8 +1995,7 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
19961995
useUser(id: string): ServerUser | null;
19971996
useUser(options?: GetUserOptions<HasTokenStore> | string): ProjectCurrentServerUser<ProjectId> | ServerUser | null {
19981997
if (typeof options === "string") {
1999-
const users = this.useUsers();
2000-
return users.find((u) => u.id === options) ?? null;
1998+
return this.useUserById(options);
20011999
} else {
20022000
// TODO this code is duplicated from the client app; fix that
20032001
this._ensurePersistentTokenStore(options?.tokenStore);

0 commit comments

Comments
 (0)