feat: distinguish managed platform users (#14207)
* feat: add isPlatformManaged property to user * do not allow deleting non managed users * refactor: rename managed user create and update inputs * refactor response code * feat: add isPlatformManaged when creating managed user * fix TS
This commit is contained in:
1 parent
bec1453148
commit
ef498c6ed6
12 files changed
+52
-27
No files matched your search
@@ -249,6 +249,7 @@ export const buildUser = <T extends Partial<UserPayload>>(
|
||||
receiveMonthlyDigestEmail: null,
|
||||
movedToProfileId: null,
|
||||
priority: user?.priority ?? null,
|
||||
isPlatformManaged: false,
|
||||
...user,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "isPlatformManaged" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -300,6 +300,7 @@ model User {
|
||||
movedToProfileId Int?
|
||||
movedToProfile Profile? @relation("moved_to_profile", fields: [movedToProfileId], references: [id], onDelete: SetNull)
|
||||
secondaryEmails SecondaryEmail[]
|
||||
isPlatformManaged Boolean @default(false)
|
||||
|
||||
@@unique([email])
|
||||
@@unique([email, username])
|
||||
|
||||
@@ -224,12 +224,14 @@ export async function createNewUsersConnectToOrgIfExists({
|
||||
parentId,
|
||||
autoAcceptEmailDomain,
|
||||
connectionInfoMap,
|
||||
isPlatformManaged,
|
||||
}: {
|
||||
usernamesOrEmails: string[];
|
||||
input: InviteMemberOptions["input"];
|
||||
parentId?: number | null;
|
||||
autoAcceptEmailDomain?: string;
|
||||
connectionInfoMap: Record<string, ReturnType<typeof getOrgConnectionInfo>>;
|
||||
isPlatformManaged?: boolean;
|
||||
}) {
|
||||
// fail if we have invalid emails
|
||||
usernamesOrEmails.forEach((usernameOrEmail) => checkInputEmailIsValid(usernameOrEmail));
|
||||
@@ -260,6 +262,7 @@ export async function createNewUsersConnectToOrgIfExists({
|
||||
email: usernameOrEmail,
|
||||
verified: true,
|
||||
invitedTo: input.teamId,
|
||||
isPlatformManaged: !!isPlatformManaged,
|
||||
organizationId: orgId || null, // If the user is invited to a child team, they are automatically added to the parent org
|
||||
...(orgId
|
||||
? {
|
||||
|
||||
Reference in new issue
Block a user