Unverified Commit 08e6ceb5 authored by Rishabh Poddar's avatar Rishabh Poddar Committed by GitHub

updates with-supertokens example (#43379)

Prevents infinite redirect loop if someone is logged in and visits a
route like `/auth/random`
parent 013844c0
......@@ -3,17 +3,19 @@ import React, { useEffect } from 'react'
import styles from '../../styles/Home.module.css'
import dynamic from 'next/dynamic'
import SuperTokens from 'supertokens-auth-react'
import { redirectToAuth } from 'supertokens-auth-react/recipe/thirdpartyemailpassword'
import { redirectToAuth } from 'supertokens-auth-react'
const SuperTokensComponentNoSSR = dynamic(
new Promise((res) => res(SuperTokens.getRoutingComponent)),
new Promise((res) => res(SuperTokens.getRoutingComponent)) as any,
{ ssr: false }
)
export default function Auth(): JSX.Element {
useEffect(() => {
if (SuperTokens.canHandleRoute() === false) {
redirectToAuth()
redirectToAuth({
redirectBack: false,
})
}
}, [])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment