Skip to content

Commit a23b718

Browse files
authored
fix(clerk-js): If password is enabled, instanceIsPasswordBased is true (#6599)
1 parent 7168243 commit a23b718

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

.changeset/khaki-ravens-cheer.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+
Update `UserSettings.instanceIsPasswordBased` to return true if password is enabled but not required.

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

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

193193
get instanceIsPasswordBased() {
194-
return Boolean(this.attributes?.password?.enabled && this.attributes.password?.required);
194+
return Boolean(this.attributes?.password?.enabled);
195195
}
196196

197197
get hasValidAuthFactor() {

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

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

packages/clerk-js/src/ui/components/SignIn/__tests__/SignInStart.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ describe('SignInStart', () => {
437437
it(`calls sign in with identifier again with only the email if the api respondes with the error ${code}`, async () => {
438438
const { wrapper, fixtures } = await createFixtures(f => {
439439
f.withEmailAddress();
440-
f.withPassword({ required: true });
440+
f.withPassword();
441441
});
442442

443443
const errJSON = {

packages/clerk-js/src/ui/components/UserProfile/__tests__/SecurityPage.test.tsx

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

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

0 commit comments

Comments
 (0)