Skip to content

Commit 3214849

Browse files
authored
User delete self fixes (#1372)
* fix(clerk-js): Fix data sourcing for delete user feature
1 parent 6041b8e commit 3214849

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/types': patch
4+
---
5+
6+
Fix to pull from the correct permissions set when displaying user delete self UI

packages/clerk-js/src/core/resources/User.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export class User extends BaseResource implements UserResource {
8080
publicMetadata: UserPublicMetadata = {};
8181
unsafeMetadata: UserUnsafeMetadata = {};
8282
lastSignInAt: Date | null = null;
83+
deleteSelfEnabled = false;
8384
updatedAt: Date | null = null;
8485
createdAt: Date | null = null;
8586

@@ -319,6 +320,8 @@ export class User extends BaseResource implements UserResource {
319320
this.backupCodeEnabled = data.backup_code_enabled;
320321
this.twoFactorEnabled = data.two_factor_enabled;
321322

323+
this.deleteSelfEnabled = data.delete_self_enabled;
324+
322325
if (data.last_sign_in_at) {
323326
this.lastSignInAt = unixEpochToDate(data.last_sign_in_at);
324327
}

packages/clerk-js/src/ui/components/UserProfile/RootPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Web3Section } from './Web3Section';
1616
import { DeleteSection } from './DeleteSection';
1717

1818
export const RootPage = withCardStateProvider(() => {
19-
const { attributes, saml, social, actions, instanceIsPasswordBased } = useEnvironment().userSettings;
19+
const { attributes, saml, social, instanceIsPasswordBased } = useEnvironment().userSettings;
2020
const card = useCardState();
2121
const user = useCoreUser();
2222
const showUsername = attributes.username.enabled;
@@ -27,7 +27,7 @@ export const RootPage = withCardStateProvider(() => {
2727
const showWeb3 = attributes.web3_wallet.enabled;
2828
const showPassword = instanceIsPasswordBased;
2929
const showMfa = getSecondFactors(attributes).length > 0;
30-
const showDelete = actions.delete_self;
30+
const showDelete = user.deleteSelfEnabled;
3131

3232
return (
3333
<Col

packages/types/src/json.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export interface UserJSON extends ClerkResourceJSON {
214214
public_metadata: UserPublicMetadata;
215215
unsafe_metadata: UserUnsafeMetadata;
216216
last_sign_in_at: number | null;
217+
delete_self_enabled: boolean;
217218
updated_at: number;
218219
created_at: number;
219220
}

packages/types/src/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export interface UserResource extends ClerkResource {
7777
publicMetadata: UserPublicMetadata;
7878
unsafeMetadata: UserUnsafeMetadata;
7979
lastSignInAt: Date | null;
80+
deleteSelfEnabled: boolean;
8081
updatedAt: Date | null;
8182
createdAt: Date | null;
8283

0 commit comments

Comments
 (0)