Skip to content

PSP-11373 Correct PIMS file/project access#5285

Open
eddherrera wants to merge 4 commits intobcgov:devfrom
eddherrera:psp-11373
Open

PSP-11373 Correct PIMS file/project access#5285
eddherrera wants to merge 4 commits intobcgov:devfrom
eddherrera:psp-11373

Conversation

@eddherrera
Copy link
Copy Markdown
Collaborator

No description provided.

@eddherrera eddherrera requested a review from asanchezr April 17, 2026 16:09
@eddherrera eddherrera self-assigned this Apr 17, 2026
@eddherrera eddherrera added the enhancement New feature or request label Apr 17, 2026
/// <returns></returns>
public static short[] GetShortArrayValue(this IDictionary<string, Microsoft.Extensions.Primitives.StringValues> dict, string key, string separator = ",")
{
return dict.TryGetValue(key, out Microsoft.Extensions.Primitives.StringValues value) ? value.ToString().Split(separator).Select(v => { return short.TryParse(v, out short iv) ? (short?)iv : null; }).Where(v => v != null).Select(v => (short)v).ToArray() : Array.Empty<short>();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please address this codeql warning

@github-actions
Copy link
Copy Markdown
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/5285

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/5285

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
8.6% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@github-actions
Copy link
Copy Markdown
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/5285

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/5285

Copy link
Copy Markdown
Collaborator

@asanchezr asanchezr left a comment

Choose a reason for hiding this comment

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

Please see comments. There are a few places where region restriction is still in place (exports mainly)

Comment on lines 108 to 111
var userRegions = pimsUser.PimsRegionUsers.Select(r => r.RegionCode).ToHashSet();
long? contractorPersonId = pimsUser.IsContractor ? pimsUser.PersonId : null;

var acqFiles = _acqFileRepository.GetAcquisitionFileExportDeep(filter, userRegions, contractorPersonId);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This needs to be updated as well. Exports are included in the story ACs:

  • Make sure this behaviour is applied consistently on dependent excel reports.

Comment on lines 183 to 186
var userRegions = pimsUser.PimsRegionUsers.Select(r => r.RegionCode).ToHashSet();
long? contractorPersonId = pimsUser.IsContractor ? pimsUser.PersonId : null;

var teamMembers = _acqFileRepository.GetTeamMembers(userRegions, contractorPersonId);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The endpoint to return "all file team-members" is also being filtered by the current user regions. I think the region restriction should be lifted as well here. I understand this was not explicitly called for in the ACs so this could be logged as a follow-up story/fix. Please reach out to Devin for feedback.

If not fixed with this PR we will need to track the change in another story

Comment on lines 519 to 522
var userRegions = pimsUser.PimsRegionUsers.Select(r => r.RegionCode).ToHashSet();
long? contractorPersonId = pimsUser.IsContractor ? pimsUser.PersonId : null;

var teamMembers = _leaseRepository.GetTeamMembers(userRegions, contractorPersonId);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment re: team-members region restriction

var pimsUser = _userRepository.GetUserInfoByKeycloakUserId(_user.GetUserKey());
long? contractorPersonId = pimsUser.IsContractor ? pimsUser.PersonId : null;

var leases = _leaseRepository.GetAllByIds(leaseIds, pimsUser.PimsRegionUsers.Select(u => u.RegionCode).ToHashSet(), contractorPersonId).ToList();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this method is called in one of the lease exports. please remove the region restriction here.

Comment on lines 68 to 71
var pimsUser = _userRepository.GetUserInfoByKeycloakUserId(_user.GetUserKey());
var userRegions = pimsUser.PimsRegionUsers.Select(r => r.RegionCode).ToHashSet();

return _projectRepository.SearchProjects(filter, userRegions, maxResult);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This correspond to the endpoints that serve the project "auto-complete". Not called explicitly in ACs so it would be okay to bundle with the other changes already mentioned that could go to a separate story. Check with Devin anyways please

Comment on lines +47 to +49
acquisitionTeamMemberPersonId: acquisitionTeamPersonId ? acquisitionTeamPersonId : null,
acquisitionTeamMemberOrganizationId: acquistionTeamOrganizationId
? acquistionTeamOrganizationId
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use isValidId to check here

leaseStatusTypes: MultiSelectOption[] = [];
tenantName = '';
expiryEndDate = '';
regionType = '';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this single-select region is not needed

searchBy = 'address';
pin = '';
pid = '';
regionCode = '';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove this field

Comment on lines +1 to +4
export interface MultiSelectOption {
id: string;
text: string;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for moving this to a shared folder

searchBy: string;
pin: string;
pid: string;
regionCode: string;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please remove

@asanchezr asanchezr added the 6.2 label Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.2 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants