diff --git a/examples/email-auth/README.md b/examples/email-auth/README.md index 2b5d28dd4..bb7f42a90 100644 --- a/examples/email-auth/README.md +++ b/examples/email-auth/README.md @@ -6,7 +6,7 @@ This example shows a complete email auth flow. It contains a NextJS app with: - a backend application The overall flow for email auth is outlined below: -![Email auth flow diagram](./auth.png) +![Email auth flow diagram](./email_auth_steps.png) This example contains an example auth page as well as a stub API endpoint for "your business" (where the email is resolved into an organization ID). The creation of the hidden iframe is abstracted by our `@turnkey/iframe-stamper` package. For more information on email auth, [check out our documentation](https://docs.turnkey.com/getting-started/email-auth). @@ -44,7 +44,7 @@ Now open `.env.local` and add the missing environment variables: - `API_PRIVATE_KEY` - `NEXT_PUBLIC_ORGANIZATION_ID` - `NEXT_PUBLIC_BASE_URL` (the `NEXT_PUBLIC` prefix makes the env variable accessible to the frontend app) -- `NEXT_PUBLIC_RECOVERY_IFRAME_URL` +- `NEXT_PUBLIC_AUTH_IFRAME_URL` ### 3/ Running the app diff --git a/examples/email-auth/email_auth_steps.png b/examples/email-auth/email_auth_steps.png new file mode 100644 index 000000000..508c4471d Binary files /dev/null and b/examples/email-auth/email_auth_steps.png differ diff --git a/examples/email-auth/email_recovery_steps.png b/examples/email-auth/email_recovery_steps.png deleted file mode 100644 index 8eea4a4d0..000000000 Binary files a/examples/email-auth/email_recovery_steps.png and /dev/null differ diff --git a/examples/email-auth/src/pages/index.tsx b/examples/email-auth/src/pages/index.tsx index a9c188729..02c9969eb 100644 --- a/examples/email-auth/src/pages/index.tsx +++ b/examples/email-auth/src/pages/index.tsx @@ -54,15 +54,12 @@ const base64UrlEncode = (challenge: ArrayBuffer): string => { }; export default function AuthPage() { - const [authResponse, setAuthResponse] = - useState(null); + const [authResponse, setAuthResponse] = useState(null); const [iframeStamper, setIframeStamper] = useState( null ); - const { - register: authFormRegister, - handleSubmit: authFormSubmit, - } = useForm(); + const { register: authFormRegister, handleSubmit: authFormSubmit } = + useForm(); const { register: injectCredentialsFormRegister, handleSubmit: injectCredentialsFormSubmit, @@ -131,10 +128,8 @@ export default function AuthPage() { const walletId = refineNonNull(wallet.walletId); const address = refineNonNull(wallet.addresses[0]); - // // Instead of simply alerting, redirect the user to your app's login page. - alert( - `SUCCESS! Wallet and new address created: ${address} ` - ); + // Instead of simply alerting, redirect the user to your app's login page. + alert(`SUCCESS! Wallet and new address created: ${address} `); }; return ( @@ -162,64 +157,57 @@ export default function AuthPage() { {!iframeStamper &&

Loading...

} - {iframeStamper && - iframeStamper.publicKey() && - authResponse === null && ( -
- - - + {iframeStamper && iframeStamper.publicKey() && authResponse === null && ( + + + + + +
+ )} + + {iframeStamper && iframeStamper.publicKey() && authResponse !== null && ( +
+ +
+ + + + )} ); }