Skip to content

Commit bf80963

Browse files
feat(clerk-js): Ability to set password from user profile when password is enabled and not required (#7379)
1 parent 615be5e commit bf80963

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

.changeset/wise-olives-drive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
When password is enabled at the instance level, but not required allow users to add a password in the user profile.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class UserSettings extends BaseResource implements UserSettingsResource {
187187
}
188188

189189
get instanceIsPasswordBased() {
190-
return Boolean(this.attributes?.password?.enabled && this.attributes.password?.required);
190+
return Boolean(this.attributes?.password?.enabled);
191191
}
192192

193193
get hasValidAuthFactor() {

packages/clerk-js/src/core/resources/__tests__/UserSettings.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ describe('UserSettings', () => {
7575
},
7676
},
7777
} as any as UserSettingsJSON);
78+
expect(sut.instanceIsPasswordBased).toEqual(true);
79+
80+
sut = new UserSettings({
81+
attributes: {
82+
password: {
83+
enabled: false,
84+
required: false,
85+
},
86+
},
87+
} as any as UserSettingsJSON);
88+
7889
expect(sut.instanceIsPasswordBased).toEqual(false);
7990
});
8091

packages/ui/src/components/UserProfile/__tests__/SecurityPage.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ describe('SecurityPage', () => {
3333

3434
it('renders the Password section if instance is password based', async () => {
3535
const { wrapper, fixtures } = await createFixtures(f => {
36-
f.withPassword({
37-
required: true,
38-
});
36+
f.withPassword();
3937
f.withUser({ email_addresses: ['[email protected]'] });
4038
});
4139
fixtures.clerk.user?.getSessions.mockReturnValue(Promise.resolve([]));

0 commit comments

Comments
 (0)