Skip to content

Commit 6406084

Browse files
committed
Create fresh SignIn on authenticateWithRedirect call
1 parent 26d273c commit 6406084

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

packages/clerk-js/src/core/resources/SignIn.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -224,24 +224,31 @@ export class SignIn extends BaseResource implements SignInResource {
224224
});
225225
};
226226

227-
public authenticateWithRedirect = async (params: AuthenticateWithRedirectParams): Promise<void> => {
228-
const { strategy, redirectUrl, redirectUrlComplete, identifier } = params || {};
229-
230-
const { firstFactorVerification } =
231-
(strategy === 'saml' || strategy === 'enterprise_sso') && this.id
232-
? await this.prepareFirstFactor({
233-
strategy,
234-
redirectUrl: SignIn.clerk.buildUrlWithAuth(redirectUrl),
235-
actionCompleteRedirectUrl: redirectUrlComplete,
236-
})
237-
: await this.create({
238-
strategy,
239-
identifier,
240-
redirectUrl: SignIn.clerk.buildUrlWithAuth(redirectUrl),
241-
actionCompleteRedirectUrl: redirectUrlComplete,
242-
});
243-
244-
const { status, externalVerificationRedirectURL } = firstFactorVerification;
227+
public authenticateWithRedirect = async ({
228+
strategy,
229+
redirectUrl,
230+
redirectUrlComplete,
231+
identifier,
232+
continueSignIn = false,
233+
}: AuthenticateWithRedirectParams): Promise<void> => {
234+
if (this.id && !continueSignIn) {
235+
await this.create({
236+
strategy,
237+
identifier,
238+
redirectUrl: SignIn.clerk.buildUrlWithAuth(redirectUrl),
239+
actionCompleteRedirectUrl: redirectUrlComplete,
240+
});
241+
}
242+
243+
if (strategy === 'saml' || strategy === 'enterprise_sso') {
244+
await this.prepareFirstFactor({
245+
strategy,
246+
redirectUrl: SignIn.clerk.buildUrlWithAuth(redirectUrl),
247+
actionCompleteRedirectUrl: redirectUrlComplete,
248+
});
249+
}
250+
251+
const { status, externalVerificationRedirectURL } = this.firstFactorVerification;
245252

246253
if (status === 'unverified' && externalVerificationRedirectURL) {
247254
windowNavigate(externalVerificationRedirectURL);

packages/clerk-js/src/ui/components/SignIn/SignInStart.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ export function _SignInStart(): JSX.Element {
336336
strategy: 'enterprise_sso',
337337
redirectUrl,
338338
redirectUrlComplete,
339+
continueSignIn: true,
339340
});
340341
};
341342

0 commit comments

Comments
 (0)