Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMBCESSMOD-5118: remove tier 1 responders visibility of restricted profiles and files #2136

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public async Task<ActionResult<IEnumerable<EvacuationFileSummary>>> GetFiles([Fr
{
if (!string.IsNullOrEmpty(registrantId) && string.IsNullOrEmpty(manualFileId))
{
var userRole = Enum.Parse<MemberRole>(currentUserRole);
var files = await evacuationSearchService.GetEvacuationFilesByRegistrantId(registrantId, userRole);
var files = await evacuationSearchService.GetEvacuationFilesByRegistrantId(registrantId);
return Ok(files);
}
else if (!string.IsNullOrEmpty(manualFileId) && string.IsNullOrEmpty(registrantId))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using EMBC.Responders.API.Services;
Expand All @@ -22,8 +21,7 @@ public partial class RegistrationsController
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<SearchResults>> Search([FromQuery] SearchParameters searchParameters)
{
var userRole = Enum.Parse<MemberRole>(currentUserRole);
var searchResults = await evacuationSearchService.SearchEvacuations(searchParameters.firstName, searchParameters.lastName, searchParameters.dateOfBirth, searchParameters.ManualFileId, userRole);
var searchResults = await evacuationSearchService.SearchEvacuations(searchParameters.firstName, searchParameters.lastName, searchParameters.dateOfBirth, searchParameters.ManualFileId);

return Ok(searchResults);
}
Expand All @@ -32,8 +30,7 @@ public async Task<ActionResult<SearchResults>> Search([FromQuery] SearchParamete
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<IEnumerable<RegistrantProfileSearchResult>>> SearchMatchingRegistrants([FromQuery] SearchParameters searchParameters)
{
var userRole = Enum.Parse<MemberRole>(currentUserRole);
var results = await evacuationSearchService.SearchRegistrantMatches(searchParameters.firstName, searchParameters.lastName, searchParameters.dateOfBirth, userRole);
var results = await evacuationSearchService.SearchRegistrantMatches(searchParameters.firstName, searchParameters.lastName, searchParameters.dateOfBirth);

return Ok(results);
}
Expand All @@ -42,8 +39,7 @@ public async Task<ActionResult<IEnumerable<RegistrantProfileSearchResult>>> Sear
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<IEnumerable<EvacuationFileSearchResult>>> SearchMatchingEvacuationFiles([FromQuery] SearchParameters searchParameters)
{
var userRole = Enum.Parse<MemberRole>(currentUserRole);
var results = await evacuationSearchService.SearchEvacuationFileMatches(searchParameters.firstName, searchParameters.lastName, searchParameters.dateOfBirth, userRole);
var results = await evacuationSearchService.SearchEvacuationFileMatches(searchParameters.firstName, searchParameters.lastName, searchParameters.dateOfBirth);
return Ok(results);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ namespace EMBC.Responders.API.Services
{
public interface IEvacuationSearchService
{
Task<SearchResults> SearchEvacuations(string firstName, string lastName, string dateOfBirth, string manualFileId, MemberRole userRole);
Task<SearchResults> SearchEvacuations(string firstName, string lastName, string dateOfBirth, string manualFileId);

Task<EvacuationFile> GetEvacuationFile(string fileId, string needsAssessmentId);

Task<IEnumerable<EvacuationFileSummary>> GetEvacuationFilesByManualFileId(string manualFileId);

Task<IEnumerable<EvacuationFileSummary>> GetEvacuationFilesByFileId(string id);

Task<IEnumerable<EvacuationFileSummary>> GetEvacuationFilesByRegistrantId(string registrantId, MemberRole userRole);
Task<IEnumerable<EvacuationFileSummary>> GetEvacuationFilesByRegistrantId(string registrantId);

Task<IEnumerable<RegistrantProfileSearchResult>> SearchRegistrantMatches(string firstName, string lastName, string dateOfBirth, MemberRole userRole);
Task<IEnumerable<RegistrantProfileSearchResult>> SearchRegistrantMatches(string firstName, string lastName, string dateOfBirth);

Task<IEnumerable<EvacuationFileSearchResult>> SearchEvacuationFileMatches(string firstName, string lastName, string dateOfBirth, MemberRole userRole);
Task<IEnumerable<EvacuationFileSearchResult>> SearchEvacuationFileMatches(string firstName, string lastName, string dateOfBirth);
}

public class SearchResults
Expand Down Expand Up @@ -81,8 +81,6 @@ public class EvacuationSearchService : IEvacuationSearchService
private readonly IMessagingClient messagingClient;
private readonly IMapper mapper;
private readonly IConfiguration configuration;
private static EvacuationFileStatus[] tier1FileStatuses = new[] { EvacuationFileStatus.Pending, EvacuationFileStatus.Active, EvacuationFileStatus.Expired };
private static EvacuationFileStatus[] tier2andAboveFileStatuses = new[] { EvacuationFileStatus.Pending, EvacuationFileStatus.Active, EvacuationFileStatus.Expired, EvacuationFileStatus.Completed };

public EvacuationSearchService(IMessagingClient messagingClient, IMapper mapper, IConfiguration configuration)
{
Expand All @@ -91,17 +89,14 @@ public EvacuationSearchService(IMessagingClient messagingClient, IMapper mapper,
this.configuration = configuration;
}

public async Task<SearchResults> SearchEvacuations(string firstName, string lastName, string dateOfBirth, string manualFileId, MemberRole userRole)
public async Task<SearchResults> SearchEvacuations(string firstName, string lastName, string dateOfBirth, string manualFileId)
{
var allowedStatues = (!string.IsNullOrEmpty(manualFileId) || userRole != MemberRole.Tier1 ? tier2andAboveFileStatuses : tier1FileStatuses)
.Select(s => Enum.Parse<EMBC.ESS.Shared.Contracts.Events.EvacuationFileStatus>(s.ToString(), true)).ToArray();
var searchResults = await messagingClient.Send(new EMBC.ESS.Shared.Contracts.Events.EvacueeSearchQuery
{
FirstName = firstName,
LastName = lastName,
DateOfBirth = dateOfBirth,
IncludeRestrictedAccess = userRole != MemberRole.Tier1,
InStatuses = allowedStatues
IncludeRestrictedAccess = true
});
return new SearchResults
{
Expand Down Expand Up @@ -160,7 +155,7 @@ public async Task<IEnumerable<EvacuationFileSummary>> GetEvacuationFilesByFileId
return new[] { mapper.Map<EvacuationFileSummary>(mappedFile) };
}

public async Task<IEnumerable<EvacuationFileSummary>> GetEvacuationFilesByRegistrantId(string? registrantId, MemberRole userRole)
public async Task<IEnumerable<EvacuationFileSummary>> GetEvacuationFilesByRegistrantId(string? registrantId)
{
var files = (await messagingClient.Send(new EMBC.ESS.Shared.Contracts.Events.EvacuationFilesQuery
{
Expand All @@ -170,30 +165,28 @@ public async Task<IEnumerable<EvacuationFileSummary>> GetEvacuationFilesByRegist
return mapper.Map<IEnumerable<EvacuationFileSummary>>(files);
}

public async Task<IEnumerable<RegistrantProfileSearchResult>> SearchRegistrantMatches(string firstName, string lastName, string dateOfBirth, MemberRole userRole)
public async Task<IEnumerable<RegistrantProfileSearchResult>> SearchRegistrantMatches(string firstName, string lastName, string dateOfBirth)
{
var searchResults = await messagingClient.Send(new EMBC.ESS.Shared.Contracts.Events.EvacueeSearchQuery
{
FirstName = firstName,
LastName = lastName,
DateOfBirth = dateOfBirth,
IncludeRestrictedAccess = userRole != MemberRole.Tier1,
IncludeRestrictedAccess = true,
IncludeRegistrantProfilesOnly = true
});
return mapper.Map<IEnumerable<RegistrantProfileSearchResult>>(searchResults.Profiles);
}

public async Task<IEnumerable<EvacuationFileSearchResult>> SearchEvacuationFileMatches(string firstName, string lastName, string dateOfBirth, MemberRole userRole)
public async Task<IEnumerable<EvacuationFileSearchResult>> SearchEvacuationFileMatches(string firstName, string lastName, string dateOfBirth)
{
var searchResults = await messagingClient.Send(new EMBC.ESS.Shared.Contracts.Events.EvacueeSearchQuery
{
FirstName = firstName,
LastName = lastName,
DateOfBirth = dateOfBirth,
IncludeRestrictedAccess = true,
IncludeEvacuationFilesOnly = true,
InStatuses = (userRole == MemberRole.Tier1 ? tier1FileStatuses : tier2andAboveFileStatuses)
.Select(s => Enum.Parse<EMBC.ESS.Shared.Contracts.Events.EvacuationFileStatus>(s.ToString(), true)).ToArray()
IncludeEvacuationFilesOnly = true
});
return mapper.Map<IEnumerable<EvacuationFileSearchResult>>(searchResults.EvacuationFiles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export enum ActionPermission {
canViewSummaryReports,
canViewDetailedReports,

canViewCompletedESSFiles,

canHideUnhideNotes,
canSeeHiddenNotes,
canSignIntoRemoteExtensions
Expand Down Expand Up @@ -88,10 +86,6 @@ export class AuthorizationService {
claimType: ClaimType.action,
claimValue: ActionPermission.canViewSummaryReports
},
{
claimType: ClaimType.action,
claimValue: ActionPermission.canViewCompletedESSFiles
},
{ claimType: ClaimType.module, claimValue: ModulePermission.team },
{ claimType: ClaimType.module, claimValue: ModulePermission.suppliers },
{ claimType: ClaimType.module, claimValue: ModulePermission.reports }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,15 @@ export class MatchedEssfilesComponent implements OnInit {
if (this.evacueeSessionService.isPaperBased) {
if (loggedInRole !== MemberRole.Tier1) {
this.essFiles = essFilesArray;
} else if (
loggedInRole === MemberRole.Tier1 &&
this.evacueeSearchService?.evacueeSearchContext?.evacueeSearchParameters?.paperFileNumber
) {
} else {
this.essFiles = essFilesArray.filter(
(files) =>
files.manualFileId ===
this.evacueeSearchService?.evacueeSearchContext?.evacueeSearchParameters?.paperFileNumber
);
}
} else {
if (loggedInRole === MemberRole.Tier1) {
this.essFiles = essFilesArray.filter((files) => files.status !== EvacuationFileStatus.Completed);
} else {
this.essFiles = essFilesArray;
}
this.essFiles = essFilesArray;
}
} else {
this.essFiles = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
</p>
<p>An ESS File associated with an active task number.</p>
</div>
<div *ngIf="hasPermission('canViewCompletedESSFiles')">
<div>
<hr class="dotted-hr" />
<p class="complete-status">
<img src="/assets/images/complete-flag.svg" height="40" width="33" /><span class="status-heading"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export class MaskFullAddressPipe implements PipeTransform {
*/
transform(address: AddressModel): SafeHtml {
if (address !== null && address !== undefined) {
const communities = this.locationService.getCommunityList();

const line1 = address.addressLine1;
const line2 = address.addressLine2;
let line3 = '';
Expand All @@ -35,20 +33,20 @@ export class MaskFullAddressPipe implements PipeTransform {

if (address.stateProvince?.name.length > 0) line3 += ', ' + address.stateProvince.code;
if (address.postalCode?.length > 0) line4 += address.postalCode + ', ';
}

line4 += address.country.name;
line4 += address.country.name;

// All values must be HTML-sanitized for us to include <br> line break.
let addressStr = _.escape(line1);
// All values must be HTML-sanitized for us to include <br> line break.
let addressStr = _.escape(line1);

if (address.addressLine2?.length > 0) addressStr += '<br>' + _.escape(line2) + ',';
else addressStr += ',';
if (address.addressLine2?.length > 0) addressStr += '<br>' + _.escape(line2) + ',';
else addressStr += ',';

if (line3.length > 0) addressStr += '<br>' + _.escape(line3);
addressStr += '<br>' + _.escape(line4);
if (line3.length > 0) addressStr += '<br>' + _.escape(line3);
addressStr += '<br>' + _.escape(line4);

return this.sanitizer.bypassSecurityTrustHtml(addressStr);
return this.sanitizer.bypassSecurityTrustHtml(addressStr);
}
}
}
}