From 0f13575e5a0b6a76786a041892b557a2b5db3219 Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Tue, 6 Jun 2023 13:32:59 -0400 Subject: [PATCH 1/4] feat(clerk-js): Add createOrganizationEnabled and deleteSelfEnabled properties to User --- packages/clerk-js/src/core/resources/User.ts | 3 +++ packages/types/src/user.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/packages/clerk-js/src/core/resources/User.ts b/packages/clerk-js/src/core/resources/User.ts index 771ab7f7c9..fc922c2ab2 100644 --- a/packages/clerk-js/src/core/resources/User.ts +++ b/packages/clerk-js/src/core/resources/User.ts @@ -319,6 +319,9 @@ export class User extends BaseResource implements UserResource { this.backupCodeEnabled = data.backup_code_enabled; this.twoFactorEnabled = data.two_factor_enabled; + this.createOrganizationEnabled = data.create_organization_enabled; + this.deleteSelfEnabled = data.delete_self_enabled; + if (data.last_sign_in_at) { this.lastSignInAt = unixEpochToDate(data.last_sign_in_at); } diff --git a/packages/types/src/user.ts b/packages/types/src/user.ts index 1f0c76d913..751abc84b4 100644 --- a/packages/types/src/user.ts +++ b/packages/types/src/user.ts @@ -77,6 +77,8 @@ export interface UserResource extends ClerkResource { publicMetadata: UserPublicMetadata; unsafeMetadata: UserUnsafeMetadata; lastSignInAt: Date | null; + createOrganizationEnabled: boolean; + deleteSelfEnabled: boolean; updatedAt: Date | null; createdAt: Date | null; From 56053c5bbb24519d348314628c789d7af6e6642d Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Fri, 16 Jun 2023 16:23:59 -0400 Subject: [PATCH 2/4] fix(clerk-js): Fix data sourcing for delete user feature --- packages/clerk-js/src/core/resources/User.ts | 2 +- packages/clerk-js/src/ui/components/UserProfile/RootPage.tsx | 4 ++-- packages/types/src/json.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/clerk-js/src/core/resources/User.ts b/packages/clerk-js/src/core/resources/User.ts index fc922c2ab2..b0d7754dbd 100644 --- a/packages/clerk-js/src/core/resources/User.ts +++ b/packages/clerk-js/src/core/resources/User.ts @@ -80,6 +80,7 @@ export class User extends BaseResource implements UserResource { publicMetadata: UserPublicMetadata = {}; unsafeMetadata: UserUnsafeMetadata = {}; lastSignInAt: Date | null = null; + deleteSelfEnabled = false; updatedAt: Date | null = null; createdAt: Date | null = null; @@ -319,7 +320,6 @@ export class User extends BaseResource implements UserResource { this.backupCodeEnabled = data.backup_code_enabled; this.twoFactorEnabled = data.two_factor_enabled; - this.createOrganizationEnabled = data.create_organization_enabled; this.deleteSelfEnabled = data.delete_self_enabled; if (data.last_sign_in_at) { diff --git a/packages/clerk-js/src/ui/components/UserProfile/RootPage.tsx b/packages/clerk-js/src/ui/components/UserProfile/RootPage.tsx index 1c05e5380e..0d27fe0a0b 100644 --- a/packages/clerk-js/src/ui/components/UserProfile/RootPage.tsx +++ b/packages/clerk-js/src/ui/components/UserProfile/RootPage.tsx @@ -16,7 +16,7 @@ import { Web3Section } from './Web3Section'; import { DeleteSection } from './DeleteSection'; export const RootPage = withCardStateProvider(() => { - const { attributes, saml, social, actions, instanceIsPasswordBased } = useEnvironment().userSettings; + const { attributes, saml, social, instanceIsPasswordBased } = useEnvironment().userSettings; const card = useCardState(); const user = useCoreUser(); const showUsername = attributes.username.enabled; @@ -27,7 +27,7 @@ export const RootPage = withCardStateProvider(() => { const showWeb3 = attributes.web3_wallet.enabled; const showPassword = instanceIsPasswordBased; const showMfa = getSecondFactors(attributes).length > 0; - const showDelete = actions.delete_self; + const showDelete = user.deleteSelfEnabled; return ( Date: Fri, 16 Jun 2023 17:17:30 -0400 Subject: [PATCH 3/4] fix(clerk-js): Fix --- packages/types/src/user.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/types/src/user.ts b/packages/types/src/user.ts index 751abc84b4..24cefdf0d4 100644 --- a/packages/types/src/user.ts +++ b/packages/types/src/user.ts @@ -77,7 +77,6 @@ export interface UserResource extends ClerkResource { publicMetadata: UserPublicMetadata; unsafeMetadata: UserUnsafeMetadata; lastSignInAt: Date | null; - createOrganizationEnabled: boolean; deleteSelfEnabled: boolean; updatedAt: Date | null; createdAt: Date | null; From 2dc6f613bcb557b36d9aba5c9d38503f8cdd8884 Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Sat, 17 Jun 2023 15:22:07 -0400 Subject: [PATCH 4/4] fix(clerk-js): Add changeset --- .changeset/silver-cheetahs-exercise.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/silver-cheetahs-exercise.md diff --git a/.changeset/silver-cheetahs-exercise.md b/.changeset/silver-cheetahs-exercise.md new file mode 100644 index 0000000000..bcfcba9467 --- /dev/null +++ b/.changeset/silver-cheetahs-exercise.md @@ -0,0 +1,6 @@ +--- +'@clerk/clerk-js': patch +'@clerk/types': patch +--- + +Fix to pull from the correct permissions set when displaying user delete self UI