Skip to content

Commit 18f3440

Browse files
fix: update role validation in InviteMembersModal to prevent admin and employee overlap (#1485)
- Modified role checks in InviteMembersModal to ensure that users with the 'employee' role do not also have the 'admin' role when processing invitations. - This change enhances the invitation logic by preventing potential role conflicts during member invitations. Additionally, updated posthog-node to version 5.8.2 and @radix-ui/react-toast to version 1.2.15 in bun.lock for improved functionality and stability. Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
1 parent b91547e commit 18f3440

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

apps/app/src/app/(app)/[orgId]/people/all/components/InviteMembersModal.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ export function InviteMembersModal({
158158

159159
// Process each invitation sequentially
160160
for (const invite of values.manualInvites) {
161-
const hasEmployeeRole = invite.roles.includes('employee');
161+
const hasEmployeeRoleAndNoAdmin =
162+
!invite.roles.includes('admin') && invite.roles.includes('employee');
162163
try {
163-
if (hasEmployeeRole) {
164+
if (hasEmployeeRoleAndNoAdmin) {
164165
await addEmployeeWithoutInvite({
165166
organizationId,
166167
email: invite.email,
@@ -318,9 +319,10 @@ export function InviteMembersModal({
318319
}
319320

320321
// Attempt to invite
321-
const hasEmployeeRole = validRoles.includes('employee');
322+
const hasEmployeeRoleAndNoAdmin =
323+
validRoles.includes('employee') && !validRoles.includes('admin');
322324
try {
323-
if (hasEmployeeRole) {
325+
if (hasEmployeeRoleAndNoAdmin) {
324326
await addEmployeeWithoutInvite({
325327
organizationId,
326328
email,

bun.lock

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)