Skip to content

Commit

Permalink
updates with-supertokens example (vercel#43379)
Browse files Browse the repository at this point in the history
Prevents infinite redirect loop if someone is logged in and visits a
route like `/auth/random`
  • Loading branch information
rishabhpoddar authored and brvnonascimento committed Nov 28, 2022
1 parent 0fae5c5 commit 8ae0693
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/with-supertokens/pages/auth/[[...path]].tsx
Expand Up @@ -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,
})
}
}, [])

Expand Down

0 comments on commit 8ae0693

Please sign in to comment.