Skip to content

Commit

Permalink
feat(clerkjs): Handle enterprise_sso missing field for sign ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikpolik committed Nov 18, 2024
1 parent 3719b8b commit d676e5e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
30 changes: 29 additions & 1 deletion packages/clerk-js/src/utils/__tests__/completeSignUpFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,35 @@ describe('completeSignUpFlow', () => {
expect(mockHandleComplete).not.toHaveBeenCalled();
expect(mockNavigate).not.toHaveBeenCalled();
expect(mockAuthenticateWithRedirect).toHaveBeenCalledWith({
strategy: 'saml',
strategy: 'enterprise_sso',
redirectUrl,
redirectUrlComplete,
continueSignUp: true,
});
});

it('initiates a Enterprise SSO flow if enterprise_sso is listed as a missing field', async () => {
const redirectUrl = 'https://www.in.gr/acs';
const redirectUrlComplete = 'https://www.in.gr/tada';

const mockSignUp = {
status: 'missing_requirements',
missingFields: ['enterprise_sso'],
authenticateWithRedirect: mockAuthenticateWithRedirect,
} as unknown as SignUpResource;

await completeSignUpFlow({
signUp: mockSignUp,
handleComplete: mockHandleComplete,
navigate: mockNavigate,
redirectUrl: 'https://www.in.gr/acs',
redirectUrlComplete: 'https://www.in.gr/tada',
});

expect(mockHandleComplete).not.toHaveBeenCalled();
expect(mockNavigate).not.toHaveBeenCalled();
expect(mockAuthenticateWithRedirect).toHaveBeenCalledWith({
strategy: 'enterprise_sso',
redirectUrl,
redirectUrlComplete,
continueSignUp: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/utils/completeSignUpFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const completeSignUpFlow = ({
if (signUp.status === 'complete') {
return handleComplete && handleComplete();
} else if (signUp.status === 'missing_requirements') {
if (signUp.missingFields.some(mf => mf === 'saml')) {
if (signUp.missingFields.some(mf => mf === 'saml' || mf === 'enterprise_sso')) {
return signUp.authenticateWithRedirect({
strategy: 'saml',
strategy: 'enterprise_sso',
redirectUrl,
redirectUrlComplete,
continueSignUp: true,
Expand Down

0 comments on commit d676e5e

Please sign in to comment.