mirror of
https://github.com/logto-io/logto.git
synced 2025-03-10 22:22:45 -05:00
fix(experience): redirect to sign-in page on socical sign-in error (#5787)
* fix(experience): redirect to sign-in page on socical sign-in error redirect user to sign-in page on social sign-in error * test(experience): add integration tests add integration tests
This commit is contained in:
parent
61e20940fe
commit
397dfcdf92
3 changed files with 27 additions and 1 deletions
|
@ -87,6 +87,11 @@ const useSingleSignOnListener = (connectorId: string) => {
|
|||
|
||||
await registerSingleSignOnIdentity(connectorId);
|
||||
},
|
||||
// Redirect to sign-in page if error is not handled by the error handlers
|
||||
global: async (error) => {
|
||||
setToast(error.message);
|
||||
navigate('/' + experience.routes.signIn);
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,11 @@ const useSocialSignInListener = (connectorId: string) => {
|
|||
await accountNotExistErrorHandler(error);
|
||||
},
|
||||
...preSignInErrorHandler,
|
||||
// Redirect to sign-in page if error is not handled by the error handlers
|
||||
global: async (error) => {
|
||||
setToast(error.message);
|
||||
navigate('/' + experience.routes.signIn);
|
||||
},
|
||||
}),
|
||||
[
|
||||
preSignInErrorHandler,
|
||||
|
|
|
@ -31,15 +31,17 @@ describe('social sign-in (with email identifier)', () => {
|
|||
// eslint-disable-next-line @silverhand/fp/no-let
|
||||
let experience: ExpectExperience;
|
||||
const socialUserId = 'foo_' + randomString();
|
||||
const ssoEmailDomain = `foo${randomString()}.com`;
|
||||
|
||||
beforeAll(async () => {
|
||||
await clearConnectorsByTypes([ConnectorType.Social, ConnectorType.Email, ConnectorType.Sms]);
|
||||
await setEmailConnector();
|
||||
await setSocialConnector();
|
||||
|
||||
const ssoConnector = await createSsoConnector({
|
||||
providerName: SsoProviderName.OIDC,
|
||||
connectorName: 'test-oidc-' + randomString(),
|
||||
domains: [`foo${randomString()}.com`],
|
||||
domains: [ssoEmailDomain],
|
||||
config: {
|
||||
clientId: 'foo',
|
||||
clientSecret: 'bar',
|
||||
|
@ -160,4 +162,18 @@ describe('social sign-in (with email identifier)', () => {
|
|||
await experience.toCompleteVerification('continue', 'Email');
|
||||
await experience.verifyThenEnd();
|
||||
});
|
||||
|
||||
it('should redirect to the sign-in page if the socialEmail is SSO email domain', async () => {
|
||||
// eslint-disable-next-line @silverhand/fp/no-mutation
|
||||
experience = new ExpectExperience(await browser.newPage());
|
||||
await experience.startWith(demoAppUrl, 'sign-in');
|
||||
await experience.toProcessSocialSignIn({
|
||||
socialUserId,
|
||||
socialEmail: generateEmail(ssoEmailDomain),
|
||||
});
|
||||
await experience.waitForToast(
|
||||
'Single sign on is enabled for this given email. Please sign in with SSO.'
|
||||
);
|
||||
experience.toBeAt('sign-in');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue