Skip to content

Commit f61ec69

Browse files
Add support for redirecting to sign in page on recovery success
1 parent 6d2700d commit f61ec69

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

lib/ts/recipe/webauthn/components/themes/recoverAccountWithToken/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ function PasskeyRecoverAccountWithTokenTheme(props: RecoverAccountWithTokenTheme
4545
throw new Error("Should never come here as we don't have back functionality");
4646
};
4747

48+
// TODO: Get the reset options as soon as the page loads and afterwards use the token
49+
// with the options.
50+
4851
const onContinueClick = useCallback(() => {
4952
// TODO: Add support to make the network call and show the next screen based
5053
// on that result.
@@ -109,7 +112,6 @@ const RecoverAccountThemeInner = (
109112
// errorMessageLabel={showPasskeyConfirmationError ? "WEBAUTHN_PASSKEY_RECOVERABLE_ERROR" : undefined}
110113
isLoading={false}
111114
onFetchError={() => {}}
112-
resetFactorList={() => {}}
113115
hideContinueWithoutPasskey
114116
/>
115117
) : props.activeScreen === RecoverAccountScreen.Success ? (

lib/ts/recipe/webauthn/components/themes/recoverAccountWithToken/success.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@
1313
* under the License.
1414
*/
1515

16+
import { redirectToAuth } from "../../../../..";
1617
import { useTranslation } from "../../../../../translation/translationContext";
1718
import { Button } from "../../../../emailpassword/components/library";
1819

1920
export const PasskeyRecoverAccountSuccess = (): JSX.Element => {
2021
const t = useTranslation();
2122

23+
const onContinueClick = async () => {
24+
await redirectToAuth({ show: "signin" });
25+
};
26+
2227
return (
2328
<div data-supertokens="passkeyRecoverAccountSuccessContainer">
2429
<div data-supertokens="header">
@@ -37,7 +42,7 @@ export const PasskeyRecoverAccountSuccess = (): JSX.Element => {
3742
disabled={false}
3843
isLoading={false}
3944
type="button"
40-
onClick={() => {}}
45+
onClick={onContinueClick}
4146
label="WEBAUTHN_EMAIL_CONTINUE_BUTTON"
4247
/>
4348
</div>

lib/ts/recipe/webauthn/components/themes/signUp/confirmation.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export const PasskeyConfirmation = withOverride(
5454
onClick={props.onContinueClick}
5555
label="WEBAUTHN_EMAIL_CONTINUE_BUTTON"
5656
/>
57-
{!props.hideContinueWithoutPasskey && <ContinueWithoutPasskey onClick={props.resetFactorList} />}
57+
{!props.hideContinueWithoutPasskey && props.resetFactorList !== undefined && (
58+
<ContinueWithoutPasskey onClick={props.resetFactorList} />
59+
)}
5860
</div>
5961
</div>
6062
);

lib/ts/recipe/webauthn/components/themes/signUp/signUpForm.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export const SignUpFormInner = withOverride(
5151
}
5252
): JSX.Element {
5353
const t = useTranslation();
54-
const defaultFooter = <ContinueWithoutPasskey onClick={props.resetFactorList} />;
54+
const defaultFooter =
55+
props.resetFactorList !== undefined ? (
56+
<ContinueWithoutPasskey onClick={props.resetFactorList} />
57+
) : undefined;
5558

5659
const onEmailContinueSuccess = useCallback(
5760
(params: ContinueOnSuccessParams) => {

lib/ts/recipe/webauthn/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export type SignUpFormProps = {
168168
recipeImplementation: RecipeImplementation;
169169
config: NormalisedConfig;
170170
onSuccess?: (result: { createdNewRecipeUser: boolean; user: User }) => void;
171-
resetFactorList: () => void;
171+
resetFactorList?: () => void;
172172
};
173173

174174
export type RecoverAccountWithTokenProps = {

0 commit comments

Comments
 (0)