Skip to content

Commit abd2e62

Browse files
committed
Part of #656
You may not invite users from Invite GUI for a CRM role Implement users_unique_crm_contact_profile
1 parent 7a91e19 commit abd2e62

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

client/src/pages/InvitationForm.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ export const InvitationForm = () => {
370370

371371
{(!isInviter && !skipRoles) && <>
372372
<SelectField value={selectedRoles}
373-
options={roles.filter(role => !selectedRoles.find(r => r.value === role.value))}
373+
options={roles.filter(role => !selectedRoles.find(r => r.value === role.value)
374+
&& isEmpty(role.crmRoleId))}
374375
name={I18n.t("invitations.roles")}
375376
toolTip={I18n.t("tooltips.rolesTooltip")}
376377
isMulti={true}

client/src/tabs/Invitations.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ export const Invitations = ({
327327
defaultSort="email"
328328
columns={columns}
329329
newLabel={I18n.t("invitations.newInvite")}
330-
showNew={!!role && isUserAllowed(AUTHORITIES.MANAGER, user) && !role.unknownInManage}
330+
showNew={!!role && isUserAllowed(AUTHORITIES.MANAGER, user) && !role.unknownInManage
331+
&& isEmpty(role.crmRoleId)}
331332
newEntityFunc={role ? () => navigate("/invitation/new", {state: role.id}) : null}
332333
customNoEntities={I18n.t(`invitations.noResults`)}
333334
loading={false}

client/src/tabs/UserRoles.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ export const UserRoles = ({role, guests}) => {
385385
defaultSort="name"
386386
columns={columns}
387387
newLabel={I18n.t(guests ? "invitations.newGuest" : isUserAllowed(AUTHORITIES.INSTITUTION_ADMIN, user) ? "invitations.new" : "invitations.newInvitation")}
388-
showNew={isUserAllowed(AUTHORITIES.MANAGER, user) && !role.unknownInManage}
388+
showNew={isUserAllowed(AUTHORITIES.MANAGER, user) && !role.unknownInManage
389+
&& isEmpty(role.crmRoleId)}
389390
newEntityFunc={() => navigate(`/invitation/new?maintainer=${guests === false}`, {state: role.id})}
390391
customNoEntities={I18n.t(`userRoles.noResults`)}
391392
loading={false}

server/src/test/java/invite/api/InvitationControllerTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,41 @@ void newInvitation() throws Exception {
108108
assertEquals(2, ((List) results.get("recipientInvitationURLs")).size());
109109
}
110110

111+
@Test
112+
void invitationForCrmRoleNotAllowed() throws Exception {
113+
AccessCookieFilter accessCookieFilter = openIDConnectFlow("/api/v1/users/login", MANAGE_SUB);
114+
Role research = roleRepository.findByName("Research").get();
115+
research.setCrmRoleId(UUID.randomUUID().toString());
116+
roleRepository.save(research);
117+
118+
InvitationRequest invitationRequest = new InvitationRequest(
119+
Authority.GUEST,
120+
"Message",
121+
Language.en,
122+
true,
123+
false,
124+
null,
125+
false,
126+
false,
127+
List.of("new@new.nl"),
128+
List.of(new Invite("new2@new.nl", "placeholder-1")),
129+
List.of(research.getId()),
130+
null,
131+
Instant.now().plus(365, ChronoUnit.DAYS),
132+
Instant.now().plus(12, ChronoUnit.DAYS));
133+
134+
given()
135+
.when()
136+
.filter(accessCookieFilter.cookieFilter())
137+
.accept(ContentType.JSON)
138+
.header(accessCookieFilter.csrfToken().getHeaderName(), accessCookieFilter.csrfToken().getToken())
139+
.contentType(ContentType.JSON)
140+
.body(invitationRequest)
141+
.post("/api/v1/invitations")
142+
.then()
143+
.statusCode(HttpStatus.NOT_FOUND.value());
144+
}
145+
111146
@Test
112147
void newInvitationNL() throws Exception {
113148
//Because the user is changed and provisionings are queried

0 commit comments

Comments
 (0)