From b63e57444e05c5dd682d32ca92ae451c07699cf4 Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Tue, 13 Feb 2024 13:22:44 +0100 Subject: [PATCH] The inviters can't change the role end date "Override of settings allowed" is enabled but ignored --- client/src/pages/InvitationForm.js | 15 ++++++++++----- client/src/utils/UserRole.js | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client/src/pages/InvitationForm.js b/client/src/pages/InvitationForm.js index 55ce5601..fca8a5c7 100644 --- a/client/src/pages/InvitationForm.js +++ b/client/src/pages/InvitationForm.js @@ -94,12 +94,16 @@ export const InvitationForm = () => { }) setOriginalRoleId(initialRole.isUserRole ? initialRole.role.id : initialRole.id); } else { + let defaultExpiryDays = 366; if (markedRoles.length === 1) { + const role = markedRoles[0] + defaultExpiryDays = role.isUserRole ? role.role.defaultExpiryDays : role.defaultExpiryDays; setSelectedRoles(markedRoles); } setInvitation({ ...invitation, - intendedAuthority: isGuest ? AUTHORITIES.GUEST : AUTHORITIES.INVITER + intendedAuthority: isGuest ? AUTHORITIES.GUEST : AUTHORITIES.INVITER, + roleExpiryDate: futureDate(defaultExpiryDays) }) } } @@ -198,6 +202,7 @@ export const InvitationForm = () => { const disabledSubmit = !initial && !isValid(); const authorityOptions = allowedAuthoritiesForInvitation(user, selectedRoles) .map(authority => ({value: authority, label: I18n.t(`access.${authority}`)})); + const overrideSettingsAllowed = selectedRoles.every(role => role.overrideSettingsAllowed); return ( <> {isInviter &&
@@ -279,7 +284,7 @@ export const InvitationForm = () => { - {selectedRoles.every(role => role.overrideSettingsAllowed) && + {overrideSettingsAllowed && setInvitation({...invitation, enforceEmailEquality: val})} @@ -287,7 +292,7 @@ export const InvitationForm = () => { info={I18n.t("tooltips.enforceEmailEqualityTooltip")} />} - {selectedRoles.every(role => role.overrideSettingsAllowed) && + {overrideSettingsAllowed && setInvitation({...invitation, eduIDOnly: val})} @@ -303,7 +308,7 @@ export const InvitationForm = () => { info={I18n.t("tooltips.guestRoleIncludedTooltip")} /> } - {selectedRoles.every(role => role.overrideSettingsAllowed) && + {overrideSettingsAllowed && { @@ -325,7 +330,7 @@ export const InvitationForm = () => { showYearDropdown={true} disabled={selectedRoles.some(role => !role.overrideSettingsAllowed)} pastDatesAllowed={config.pastDateAllowed} - allowNull={selectedRoles.every(role => role.overrideSettingsAllowed) && invitation.intendedAuthority !== AUTHORITIES.GUEST} + allowNull={overrideSettingsAllowed && invitation.intendedAuthority !== AUTHORITIES.GUEST} minDate={futureDate(1, invitation.expiryDate)} name={I18n.t("invitations.roleExpiryDate")} toolTip={I18n.t("tooltips.roleExpiryDateTooltip")}/>} diff --git a/client/src/utils/UserRole.js b/client/src/utils/UserRole.js index 333797f6..10ca0590 100644 --- a/client/src/utils/UserRole.js +++ b/client/src/utils/UserRole.js @@ -119,6 +119,7 @@ export const markAndFilterRoles = (user, allRoles, locale, multiple, separator) userRole.defaultExpiryDays = role.defaultExpiryDays; userRole.eduIDOnly = role.eduIDOnly; userRole.enforceEmailEquality = role.enforceEmailEquality; + userRole.overrideSettingsAllowed = role.overrideSettingsAllowed; userRole.applicationName = role.applicationName; userRole.applicationOrganizationName = role.applicationOrganizationName; userRole.applicationMaps = role.applicationMaps;