Skip to content

fix: optimise users query frontend and backend#1369

Open
yoganandaness wants to merge 5 commits intodevelopfrom
SWAP-5236-uo-search-user-by-email
Open

fix: optimise users query frontend and backend#1369
yoganandaness wants to merge 5 commits intodevelopfrom
SWAP-5236-uo-search-user-by-email

Conversation

@yoganandaness
Copy link
Contributor

Description

This PR introduces a refactor and consolidation of user and participant selection components across the frontend, along with backend enhancements to user search and access control.

Motivation and Context

The participant selection logic had diverged over time, with multiple overlapping components and proposal-specific variations. This increased cognitive load, duplicated logic, and made future changes error-prone.

This refactor consolidates participant selection into clearer, reusable components, improving maintainability and consistency across the application. Removing legacy components and unused props reduces technical debt and simplifies the codebase.

On the backend, expanding search fields improves administrative and user workflows when locating users. Tightening access control and removing reliance on externally provided userId parameters strengthens security by ensuring queries are scoped to the authenticated agent context.

How Has This Been Tested

Manually

Fixes

N/A

Changes

  • Refactor: Consolidated and renamed participant selector components across the frontend.
  • Cleanup: Removed ProposalParticipantLegacy.tsx and eliminated unused props and proposal-specific modal logic.
  • Enhancement: Expanded backend user search to include email and oidc_sub.
  • Security: Strengthened role-based access control for user queries.
  • Security/Correctness: Updated getPreviousCollaborators to use agent.id and guard against missing agent.

Depends on

None.

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@yoganandaness yoganandaness requested a review from a team as a code owner February 22, 2026 21:07
@yoganandaness yoganandaness requested review from EdwardHaynes and removed request for a team February 22, 2026 21:07
@yoganandaness yoganandaness force-pushed the SWAP-5236-uo-search-user-by-email branch from 506f41b to a135e98 Compare February 22, 2026 21:10
}

@Authorized()
@Authorized([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I was wonder what is the reason of adding this? I think the least permissive one is the USER. we also add now PROPOSAL_READER, so we would need to remember adding it here as well as for all the future roles. Do you want to exclude a role here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy that.


@Authorized()
@Authorized([Roles.USER_OFFICER])
async getPreviousCollaborators(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaking: I think this is used in participant selector and needed for the USER role as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My Mistake. Thanks a lot.

userRole?: UserRole,
subtractUsers?: [number]
) {
if (!agent) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I tink we normally mark agent with "!" if there is @Authorized abobe the function, as for some reason TS can not infer that the agent must be defined. Or i wonder can you just change 146 and remove the null ? Not a strong oppinion here just observation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we take this to a separate improvement? I see some potential fix to this overall. @jekabs-karklins

title={t('instrumentSci')}
invitationUserRole={UserRole.INSTRUMENT_SCIENTIST}
/>
{isUserOfficer && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: What happens if this condition is not in place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Technique page is currently accessible only to the User Officer. Check here.

The PeopleSelectorModal is the generic modal, that is used to assign people to different entities including Technique. Since the Technique - Scientist assignment is a User Officer's only role, I thought to add this condition, so that other Role can't access this, if this component is used in the future

This is just a frontend condition and doesn't add a lot of value, other than self-documentation.

Let me know if you would like to remove this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to remove

Copy link
Contributor

@jekabs-karklins jekabs-karklins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

title={t('instrumentSci')}
invitationUserRole={UserRole.INSTRUMENT_SCIENTIST}
/>
{isUserOfficer && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants