@ministryofjustice/hmpps-prison-permissions-lib 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/data/hmppsPrisonerSearch/interfaces/Prisoner.d.ts +2 -0
- package/dist/index.cjs +8 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +8 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/testUtils/TestScenario.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Please use this to capture reasoning behind changes:
|
|
4
4
|
|
|
5
|
+
# 2.1.0
|
|
6
|
+
Adds the sensitive edits role to the edit_contacts permission so users can edit Next of Kin and Emergency contacts in the prisoner profile without requiring Contacts Administrator or Authoriser roles.
|
|
7
|
+
|
|
8
|
+
# 2.0.1
|
|
9
|
+
Fixes incorrect usage of `previousPrisonId` and `previousPrisonLeavingDate` when checking contacts read permissions. These are only used in the context of transfers, not releases. The correct ones now in use are `lastPrisonId` and `releaseDate`.
|
|
10
|
+
|
|
5
11
|
# 2.0.0
|
|
6
12
|
Replaced contacts read permissions check with one that handles released prisoners differently. Checks for current prisoners are unaffected.
|
|
7
13
|
|
package/dist/index.cjs
CHANGED
|
@@ -122,8 +122,8 @@ const isTransferring = (prisoner) => {
|
|
|
122
122
|
};
|
|
123
123
|
const wasReleasedWithinThreeYears = (prisoner) => {
|
|
124
124
|
return (isReleased(prisoner) &&
|
|
125
|
-
!!prisoner.
|
|
126
|
-
Date.parse(prisoner.
|
|
125
|
+
!!prisoner.releaseDate &&
|
|
126
|
+
Date.parse(prisoner.releaseDate) > Date.now() - 3 * 365 * 24 * 60 * 60 * 1000);
|
|
127
127
|
};
|
|
128
128
|
function userHasSomeRolesFrom(rolesToCheck, user) {
|
|
129
129
|
return (rolesToCheck.length === 0 ||
|
|
@@ -758,7 +758,7 @@ const contactsReadCheck = matchBaseCheckAnd({
|
|
|
758
758
|
return exports.PermissionCheckStatus.ROLE_NOT_PRESENT;
|
|
759
759
|
if (!wasReleasedWithinThreeYears(prisoner))
|
|
760
760
|
return exports.PermissionCheckStatus.EXCEEDS_TIME_RESTRICTION;
|
|
761
|
-
if (!isInUsersCaseLoad(prisoner.
|
|
761
|
+
if (!isInUsersCaseLoad(prisoner.lastPrisonId, user))
|
|
762
762
|
return exports.PermissionCheckStatus.NOT_IN_CASELOAD;
|
|
763
763
|
return exports.PermissionCheckStatus.OK;
|
|
764
764
|
}
|
|
@@ -776,7 +776,11 @@ function personalRelationshipsCheck(context) {
|
|
|
776
776
|
...check(exports.PersonalRelationshipsPermission.read_emergency_contacts, baseCheck),
|
|
777
777
|
...check(exports.PersonalRelationshipsPermission.edit_emergency_contacts, prisonerProfileSensitiveEditCheck),
|
|
778
778
|
...check(exports.PersonalRelationshipsPermission.read_contacts, contactsReadCheck),
|
|
779
|
-
...check(exports.PersonalRelationshipsPermission.edit_contacts, inUsersCaseLoadAndUserHasSomeRolesFrom([
|
|
779
|
+
...check(exports.PersonalRelationshipsPermission.edit_contacts, inUsersCaseLoadAndUserHasSomeRolesFrom([
|
|
780
|
+
exports.Role.ContactsAdministrator,
|
|
781
|
+
exports.Role.ContactsAuthoriser,
|
|
782
|
+
exports.Role.PrisonerProfileSensitiveEdit,
|
|
783
|
+
])),
|
|
780
784
|
...check(exports.PersonalRelationshipsPermission.edit_contact_restrictions, inUsersCaseLoadAndUserHasRole(exports.Role.ContactsAuthoriser)),
|
|
781
785
|
...check(exports.PersonalRelationshipsPermission.edit_contact_visit_approval, inUsersCaseLoadAndUserHasRole(exports.Role.ContactsAuthoriser)),
|
|
782
786
|
};
|