Skip to content

Commit 5065b04

Browse files
Add more fixes for properly rendering the full page passkey page
1 parent b6b7ce3 commit 5065b04

File tree

6 files changed

+9
-17
lines changed

6 files changed

+9
-17
lines changed

lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ async function buildAndSetChildProps(
508508

509509
for (const a of authComps) {
510510
if (a.type === "FULL_PAGE") {
511-
const preloadRes = await a.preloadInfoAndRunChecks(firstFactors, userContext);
511+
const preloadRes = await a.preloadInfoAndRunChecks(firstFactors, userContext, isSignUp);
512512
// We skip setting if the auth page unmounted while we were checking
513513
// if we should show any full page comps
514514
if (abort.aborted) {

lib/ts/recipe/webauthn/components/features/signUp/index.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ import { useUserContext } from "../../../../../usercontext";
2626
import { useRethrowInRender } from "../../../../../utils";
2727
import Session from "../../../../session/recipe";
2828
import useSessionContext from "../../../../session/useSessionContext";
29-
import { WEBAUTHN_IS_SIGN_UP_STATE_KEY } from "../../../constants";
3029
import { ContinueWithPasskeyTheme } from "../../themes/continueWithPasskey";
3130
import SignUpTheme from "../../themes/signUp";
3231
import { defaultTranslationsWebauthn } from "../../themes/translations";
3332

3433
import type { UserContext, PartialAuthComponentProps } from "../../../../../types";
3534
import type { AuthSuccessContext } from "../../../../authRecipe/types";
3635
import type Recipe from "../../../recipe";
37-
import type { ComponentOverrideMap, ContinueFor } from "../../../types";
36+
import type { ComponentOverrideMap } from "../../../types";
3837
import type { SignUpThemeProps } from "../../../types";
3938
import type { User } from "supertokens-web-js/types";
4039

@@ -156,22 +155,14 @@ export const SignUpWithPasskeyFeature: React.FC<
156155
> = (props) => {
157156
const recipeComponentOverrides = props.useComponentOverrides();
158157

159-
const handleContinueClick = React.useCallback(
160-
(continueFor: ContinueFor) => {
161-
props.setFactorList(props.factorIds);
162-
props.userContext[WEBAUTHN_IS_SIGN_UP_STATE_KEY] = continueFor === "SIGN_UP";
163-
},
164-
[props]
165-
);
166-
167158
return (
168159
<AuthComponentWrapper recipeComponentOverrides={recipeComponentOverrides}>
169160
<FeatureWrapper
170161
useShadowDom={SuperTokens.getInstanceOrThrow().useShadowDom}
171162
defaultStore={defaultTranslationsWebauthn}>
172163
<ContinueWithPasskeyTheme
173164
{...props}
174-
continueWithPasskeyClicked={handleContinueClick}
165+
continueWithPasskeyClicked={() => props.setFactorList(props.factorIds)}
175166
config={props.recipe.config}
176167
continueFor="SIGN_UP"
177168
/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const SignUpForm = withOverride(
5555
if (email === undefined) {
5656
throw new STGeneralError("GENERAL_ERROR_EMAIL_UNDEFINED");
5757
}
58+
// TODO: Define actual code
5859
return null;
5960
}}
6061
validateOnBlur={false}

lib/ts/recipe/webauthn/constants.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/ts/recipe/webauthn/prebuiltui.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { useRecipeComponentOverrideContext } from "./componentOverrideContext";
88
import SignInWithPasskeyFeature from "./components/features/signIn";
99
import SignUpFeature, { SignUpWithPasskeyFeature } from "./components/features/signUp";
1010
import { defaultTranslationsWebauthn } from "./components/themes/translations";
11-
import { WEBAUTHN_IS_SIGN_UP_STATE_KEY } from "./constants";
1211
import WebauthnRecipe from "./recipe";
1312

1413
import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext";
@@ -84,8 +83,7 @@ export class WebauthnPreBuiltUI extends RecipeRouter {
8483
return [
8584
{
8685
type: "FULL_PAGE",
87-
async preloadInfoAndRunChecks(firstFactors, userContext) {
88-
const isSignUp = userContext[WEBAUTHN_IS_SIGN_UP_STATE_KEY] || false;
86+
async preloadInfoAndRunChecks(firstFactors, _, isSignUp) {
8987
return {
9088
shouldDisplay:
9189
isSignUp && firstFactors.length === 1 && firstFactors.includes(FactorIds.WEBAUTHN),
@@ -133,6 +131,8 @@ export class WebauthnPreBuiltUI extends RecipeRouter {
133131
];
134132
}
135133

134+
public requiresSignUpPage = true;
135+
136136
// For tests
137137
static reset(): void {
138138
if (!isTest()) {

lib/ts/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ export type FullPageAuthComponent<PreloadInfoType = any> = {
437437
type: "FULL_PAGE";
438438
preloadInfoAndRunChecks: (
439439
firstFactors: string[],
440-
userContext: UserContext
440+
userContext: UserContext,
441+
isSignUp: boolean
441442
) => Promise<{ shouldDisplay: true; preloadInfo: PreloadInfoType } | { shouldDisplay: false }>;
442443
component: React.FC<FullPageAuthComponentProps<PreloadInfoType>>;
443444
};

0 commit comments

Comments
 (0)