Skip to content

Commit e54c49f

Browse files
committed
Bugfix for scoping authorities in new invitations
1 parent 32d305f commit e54c49f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

client/src/utils/UserRole.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,20 @@ export const allowedAuthoritiesForInvitation = (user, selectedRoles) => {
190190
.filter(auth => AUTHORITIES_HIERARCHY[auth] > AUTHORITIES_HIERARCHY[allowedAuthority]);
191191
}
192192
}
193-
const userRolesForSelectedRoles = selectedRoles
194-
.map(role => role.isUserRole ? role.role : role)
195-
.filter(role => (!isEmpty(user.organizationGUID) && user.organizationGUID === role.organizationGUID) ||
196-
user.userRoles.some(userRole => userRole.role.id === role.id))
197-
.filter(userRole => !isEmpty(userRole));
198-
199-
if (!isUserAllowed(AUTHORITIES.INVITER, user)) {
200-
return [];
201-
}
202193
if (isEmpty(selectedRoles)) {
203194
const authority = highestAuthority(user);
204195
return Object.keys(AUTHORITIES)
205196
.filter(auth => AUTHORITIES_HIERARCHY[auth] > AUTHORITIES_HIERARCHY[authority]);
206197
}
198+
const userRolesForSelectedRoles = selectedRoles
199+
.filter(role => {
200+
role = role.isUserRole ? role.role : role;
201+
return (!isEmpty(user.organizationGUID) && user.organizationGUID === role.organizationGUID) ||
202+
user.userRoles.some(userRole => userRole.role.id === role.id)
203+
});
204+
if (!isUserAllowed(AUTHORITIES.INVITER, user)) {
205+
return [];
206+
}
207207
const leastImportantAuthority = userRolesForSelectedRoles
208208
.reduce((acc, userRole) => {
209209
if (acc === null || AUTHORITIES_HIERARCHY[userRole.authority] > AUTHORITIES_HIERARCHY[acc]) {

0 commit comments

Comments
 (0)