Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(experience): redirect to sign-in page on socical sign-in error #5787

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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