Skip to content

Commit

Permalink
Better user ID search
Browse files Browse the repository at this point in the history
  • Loading branch information
N2D4 committed Feb 1, 2025
1 parent d90128e commit fca9f57
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/backend/src/app/api/v1/users/crud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ export const usersCrudHandlers = createLazyProxy(() => createCrudHandlers(usersC
return user;
},
onList: async ({ auth, query }) => {
const queryWithoutSpecialChars = query.query?.replace(/[^a-zA-Z0-9\-_.]/g, '');

const where = {
projectId: auth.project.id,
...query.team_id ? {
Expand All @@ -466,9 +468,11 @@ export const usersCrudHandlers = createLazyProxy(() => createCrudHandlers(usersC
} : {},
...query.query ? {
OR: [
...(isUuid(query.query) ? [{
equals: query.query
}] : []),
...isUuid(queryWithoutSpecialChars) ? [{
projectUserId: {
equals: queryWithoutSpecialChars
},
}] : [],
{
displayName: {
contains: query.query,
Expand Down

0 comments on commit fca9f57

Please sign in to comment.