diff --git a/packages/core/src/routes/interaction/utils/sign-in-experience-valiation.test.ts b/packages/core/src/routes/interaction/utils/sign-in-experience-valiation.test.ts index b4a7be460..23c3e2810 100644 --- a/packages/core/src/routes/interaction/utils/sign-in-experience-valiation.test.ts +++ b/packages/core/src/routes/interaction/utils/sign-in-experience-valiation.test.ts @@ -266,6 +266,36 @@ describe('identifier validation', () => { }); }).not.toThrow(); }); + + it('connector phone should not throw', () => { + const identifier = { phone: '123456', connectorId: 'logto' }; + + expect(() => { + verifyIdentifierSettings(identifier, { + ...mockSignInExperience, + signIn: { + methods: mockSignInExperience.signIn.methods.filter( + ({ identifier }) => identifier !== SignInIdentifier.Phone + ), + }, + }); + }).not.toThrow(); + }); + + it('connector email should not throw', () => { + const identifier = { email: 'foo@logto.io', connectorId: 'logto' }; + + expect(() => { + verifyIdentifierSettings(identifier, { + ...mockSignInExperience, + signIn: { + methods: mockSignInExperience.signIn.methods.filter( + ({ identifier }) => identifier !== SignInIdentifier.Email + ), + }, + }); + }).not.toThrow(); + }); }); describe('profile validation', () => { diff --git a/packages/core/src/routes/interaction/utils/sign-in-experience-validation.ts b/packages/core/src/routes/interaction/utils/sign-in-experience-validation.ts index f8c113f4c..670991f7f 100644 --- a/packages/core/src/routes/interaction/utils/sign-in-experience-validation.ts +++ b/packages/core/src/routes/interaction/utils/sign-in-experience-validation.ts @@ -43,6 +43,12 @@ export const verifyIdentifierSettings = ( return; } + // Social Identifier TODO: @darcy, @sijie + // should not verify connector related identifier here + if ('connectorId' in identifier) { + return; + } + // Email Identifier if ('email' in identifier) { assertThat( @@ -87,7 +93,7 @@ export const verifyIdentifierSettings = ( return false; } - // Phone verificationCode Verification: SignIn verificationCode enabled or SignUp Email verify enabled + // Phone verificationCode Verification: SignIn verificationCode enabled or SignUp Phone verify enabled if ( 'verificationCode' in identifier && !verificationCode && @@ -102,8 +108,6 @@ export const verifyIdentifierSettings = ( forbiddenIdentifierError() ); } - - // Social Identifier TODO: @darcy, @sijie }; export const verifyProfileSettings = (profile: Profile, { signUp }: SignInExperience) => {