From 0e2c77369f64703131806c1cbc0ec6d3f7b9dcd3 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Wed, 6 Dec 2023 19:36:35 +0530 Subject: [PATCH 1/7] feat: Add getRedirectionURL docs --- .../frontend-hooks/redirection-callback.mdx | 2 +- .../embed-sign-in-up-form.mdx | 159 +++++++++++++++++- .../frontend-hooks/redirection-callback.mdx | 2 +- .../embed-sign-in-up-form.mdx | 158 ++++++++++++++++- .../further-reading/passwordless-login.mdx | 6 +- .../frontend-hooks/redirection-callback.mdx | 2 +- .../embed-sign-in-up-form.mdx | 156 ++++++++++++++++- .../frontend-hooks/redirection-callback.mdx | 2 +- .../embed-sign-in-up-form.mdx | 156 ++++++++++++++++- .../frontend-hooks/redirection-callback.mdx | 2 +- .../embed-sign-in-up-form.mdx | 159 +++++++++++++++++- .../further-reading/passwordless-login.mdx | 6 +- 12 files changed, 785 insertions(+), 25 deletions(-) diff --git a/v2/emailpassword/advanced-customizations/frontend-hooks/redirection-callback.mdx b/v2/emailpassword/advanced-customizations/frontend-hooks/redirection-callback.mdx index 41d3dde59..384a4221a 100644 --- a/v2/emailpassword/advanced-customizations/frontend-hooks/redirection-callback.mdx +++ b/v2/emailpassword/advanced-customizations/frontend-hooks/redirection-callback.mdx @@ -9,7 +9,7 @@ import TabItem from '@theme/TabItem'; # Redirection Callback Hook -This function is used to change where the user is redirected to post certain actions. For example, you can use this to redirect a user to a specific URL post sign in / up. +This function is used to change where the user is redirected to post certain actions. For example, you can use this to redirect a user to a specific URL post sign in / up. If you're embedding the sign in / up components in a popup and wish to disable redirection entirely, simply return `null`. diff --git a/v2/emailpassword/common-customizations/embed-sign-in-up-form.mdx b/v2/emailpassword/common-customizations/embed-sign-in-up-form.mdx index 0324be4ab..68eb87968 100644 --- a/v2/emailpassword/common-customizations/embed-sign-in-up-form.mdx +++ b/v2/emailpassword/common-customizations/embed-sign-in-up-form.mdx @@ -6,6 +6,8 @@ hide_title: true import FrontendSDKTabs from "/src/components/tabs/FrontendSDKTabs" import TabItem from '@theme/TabItem'; +import {Question, Answer}from "/src/components/question" +import RRDVersionSubTabs from "/src/components/tabs/RRDVersionSubTabs" # Embed Sign In / Up form in a page @@ -46,10 +48,117 @@ If you navigate to `/auth`, you should not see the widget anymore. ## Step 2: Render the component yourself -For example if you would like to show the login form in our own component which renders custom UI around it, and is shown only of the user is logged in, then we can: +For example if you would like to show the login form in our own component which renders custom UI around it, and is shown only if the user is logged in, then we can: + + + + + + + +```tsx +import React from "react"; +// highlight-start +import { SignInAndUp } from 'supertokens-auth-react/recipe/emailpassword/prebuiltui'; +import Session from "supertokens-auth-react/recipe/session"; +// highlight-end +// @ts-ignore +import Header from "./header"; +// @ts-ignore +import Footer from "./footer"; +import { useNavigate } from "react-router-dom"; + +function MyLandingPage() { + let sessionContext = Session.useSessionContext(); + const navigate = useNavigate(); + if (sessionContext.loading) { + return null; + } + if (sessionContext.doesSessionExist) { + // We wrap this with so that + // all claims are validated before showing the logged in UI. + // For example, if email verification is switched on, and + // the user's email is not verified, then + // will redirect to the email verification page. + return ( + +
+ You are logged in! +