mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-24 13:48:45 +00:00
fix: increase performance of ListUser by login name ignore case (#12350)
# Which Problems Are Solved Login v2 uses the `users.v2.ListUsers`-endpoint to get a user by login name. This query had an inefficient `WHERE`-clause. # How the Problems Are Solved Update the view and use a specific clause for this query. # Additional information Added in https://github.com/zitadel/zitadel/pull/10475 --------- Co-authored-by: Marco A. <[email protected]> Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
co-authored by
Marco A.
Livio Spring
parent
561da54ff7
commit
f9995ee39c
@@ -587,6 +587,8 @@ export type ListUsersCommand = WithServiceConfig<{
|
||||
organizationId?: string;
|
||||
}>;
|
||||
|
||||
const userLookupQuery = { limit: 2 };
|
||||
|
||||
export async function listUsers({ serviceConfig, loginName, userName, phone, email, organizationId }: ListUsersCommand) {
|
||||
const queries: SearchQuery[] = [];
|
||||
|
||||
@@ -672,7 +674,7 @@ export async function listUsers({ serviceConfig, loginName, userName, phone, ema
|
||||
|
||||
const userService: Client<typeof UserService> = await createServiceForHost(UserService, serviceConfig);
|
||||
|
||||
return userService.listUsers({ queries });
|
||||
return userService.listUsers({ query: userLookupQuery, queries });
|
||||
}
|
||||
|
||||
export type SearchUsersCommand = WithServiceConfig<{
|
||||
@@ -755,7 +757,7 @@ export async function searchUsers({
|
||||
|
||||
const userService: Client<typeof UserService> = await createServiceForHost(UserService, serviceConfig);
|
||||
|
||||
const loginNameResult = await userService.listUsers({ queries });
|
||||
const loginNameResult = await userService.listUsers({ query: userLookupQuery, queries });
|
||||
|
||||
if (!loginNameResult || !loginNameResult.details) {
|
||||
return { error: t("errors.errorOccured") };
|
||||
@@ -817,6 +819,7 @@ export async function searchUsers({
|
||||
}
|
||||
|
||||
const emailOrPhoneResult = await userService.listUsers({
|
||||
query: userLookupQuery,
|
||||
queries: emailAndPhoneQueries,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user