Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-ravens-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Update `UserSettings.instanceIsPasswordBased` to return true if password is enabled but not required.
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/resources/UserSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class UserSettings extends BaseResource implements UserSettingsResource {
}

get instanceIsPasswordBased() {
return Boolean(this.attributes?.password?.enabled && this.attributes.password?.required);
return Boolean(this.attributes?.password?.enabled);
}

get hasValidAuthFactor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ describe('UserSettings', () => {
},
},
} as any as UserSettingsJSON);

expect(sut.instanceIsPasswordBased).toEqual(true);

sut = new UserSettings({
attributes: {
password: {
enabled: false,
required: false,
},
},
} as any as UserSettingsJSON);

expect(sut.instanceIsPasswordBased).toEqual(false);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ describe('SignInStart', () => {
it(`calls sign in with identifier again with only the email if the api respondes with the error ${code}`, async () => {
const { wrapper, fixtures } = await createFixtures(f => {
f.withEmailAddress();
f.withPassword({ required: true });
f.withPassword();
});

const errJSON = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ describe('SecurityPage', () => {

it('renders the Password section if instance is password based', async () => {
const { wrapper, fixtures } = await createFixtures(f => {
f.withPassword({
required: true,
});
f.withPassword();
f.withUser({ email_addresses: ['[email protected]'] });
});
fixtures.clerk.user?.getSessions.mockReturnValue(Promise.resolve([]));
Expand Down