Skip to content

Commit

Permalink
[PM-4395] Block reseller org invites if they outnumber available seats (
Browse files Browse the repository at this point in the history
#6698)

* Add Toast when reseller org invites over seat limit

* Set validation error when reseller org invited members outnumber seats

* Thomas' feedback
  • Loading branch information
amorask-bitwarden authored Nov 20, 2023
1 parent 1dbff31 commit 6f9c6d0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface MemberDialogParams {
allOrganizationUserEmails: string[];
usesKeyConnector: boolean;
initialTab?: MemberDialogTab;
numConfirmedMembers: number;
}

export enum MemberDialogResult {
Expand Down Expand Up @@ -383,6 +384,15 @@ export class MemberDialogComponent implements OnInit, OnDestroy {
});
return;
}
if (
this.organization.hasReseller &&
this.params.numConfirmedMembers + emails.length > this.organization.seats
) {
this.formGroup.controls.emails.setErrors({
tooManyEmails: { message: this.i18nService.t("seatLimitReachedContactYourProvider") },
});
return;
}
await this.userService.invite(emails, userView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,15 @@ export class PeopleComponent
}

async edit(user: OrganizationUserView, initialTab: MemberDialogTab = MemberDialogTab.Role) {
if (!user && this.organization.hasReseller && this.organization.seats === this.confirmedCount) {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("seatLimitReached"),
this.i18nService.t("contactYourProvider")
);
return;
}

// Invite User: Add Flow
// Click on user email: Edit Flow

Expand All @@ -450,6 +459,7 @@ export class PeopleComponent
allOrganizationUserEmails: this.allUsers?.map((user) => user.email) ?? [],
usesKeyConnector: user?.usesKeyConnector,
initialTab: initialTab,
numConfirmedMembers: this.confirmedCount,
},
});

Expand Down
9 changes: 9 additions & 0 deletions apps/web/src/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7398,5 +7398,14 @@
},
"unexpectedErrorSend": {
"message": "An unexpected error has occurred while loading this Send. Try again later."
},
"seatLimitReached": {
"message": "Seat limit has been reached"
},
"contactYourProvider": {
"message": "Contact your provider to purchase additional seats."
},
"seatLimitReachedContactYourProvider": {
"message": "Seat limit has been reached. Contact your provider to purchase additional seats."
}
}
4 changes: 4 additions & 0 deletions libs/common/src/admin-console/models/domain/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ export class Organization {
return this.providerId != null || this.providerName != null;
}

get hasReseller() {
return this.hasProvider && this.providerType === ProviderType.Reseller;
}

get canAccessSecretsManager() {
return this.useSecretsManager && this.accessSecretsManager;
}
Expand Down

0 comments on commit 6f9c6d0

Please sign in to comment.