Skip to content

Commit

Permalink
The inviters can't change the role end date
Browse files Browse the repository at this point in the history
"Override of settings allowed" is enabled but ignored
  • Loading branch information
oharsta committed Feb 13, 2024
1 parent 7be9a75 commit b63e574
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions client/src/pages/InvitationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
Expand Down Expand Up @@ -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 && <div className="card-containers">
Expand Down Expand Up @@ -279,15 +284,15 @@ export const InvitationForm = () => {
<UpIcon/>
</a>

{selectedRoles.every(role => role.overrideSettingsAllowed) &&
{overrideSettingsAllowed &&
<SwitchField name={"enforceEmailEquality"}
value={invitation.enforceEmailEquality || false}
onChange={val => setInvitation({...invitation, enforceEmailEquality: val})}
label={I18n.t("invitations.enforceEmailEquality")}
info={I18n.t("tooltips.enforceEmailEqualityTooltip")}
/>}

{selectedRoles.every(role => role.overrideSettingsAllowed) &&
{overrideSettingsAllowed &&
<SwitchField name={"eduIDOnly"}
value={invitation.eduIDOnly || false}
onChange={val => setInvitation({...invitation, eduIDOnly: val})}
Expand All @@ -303,7 +308,7 @@ export const InvitationForm = () => {
info={I18n.t("tooltips.guestRoleIncludedTooltip")}
/>
}
{selectedRoles.every(role => role.overrideSettingsAllowed) &&
{overrideSettingsAllowed &&
<SwitchField name={"roleExpiryDate"}
value={customRoleExpiryDate}
onChange={() => {
Expand All @@ -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")}/>}
Expand Down
1 change: 1 addition & 0 deletions client/src/utils/UserRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b63e574

Please sign in to comment.