mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
fix: updates code snippets to use latest version of supertokens-auth-react
This commit is contained in:
1 parent
c5be38e52a
commit
59bed95053
1 file changed
+10
-11
@@ -260,26 +260,21 @@ Now that our backend is setup we can modify our frontend to retrieve the user's
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import Head from 'next/head'
|
||||
import styles from '../styles/Home.module.css'
|
||||
import ThirdPartyEmailPassword from 'supertokens-auth-react/recipe/thirdpartyemailpassword'
|
||||
import ThirdPartyEmailPassword, {
|
||||
ThirdPartyEmailPasswordAuth,
|
||||
} from "supertokens-auth-react/recipe/thirdpartyemailpassword";
|
||||
import dynamic from 'next/dynamic'
|
||||
import { useSessionContext } from 'supertokens-auth-react/recipe/session'
|
||||
import { getSupabase } from '../utils/supabase'
|
||||
|
||||
const ThirdPartyEmailPasswordAuthWrapper = dynamic(
|
||||
new Promise<typeof ThirdPartyEmailPassword.ThirdPartyEmailPasswordAuth>((res) =>
|
||||
res(ThirdPartyEmailPassword.ThirdPartyEmailPasswordAuth)
|
||||
),
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
// We will wrap the ProtectedPage component with the ThirdPartyEmailPasswordAuthWrapper so only an
|
||||
// We will wrap the ProtectedPage component with the ThirdPartyEmailPasswordAuth so only an
|
||||
// authenticated user can access it. This will also allow us to access the users session information
|
||||
// within the component.
|
||||
<ThirdPartyEmailPasswordAuthWrapper>
|
||||
<ThirdPartyEmailPasswordAuth>
|
||||
<ProtectedPage />
|
||||
</ThirdPartyEmailPasswordAuthWrapper>
|
||||
</ThirdPartyEmailPasswordAuth>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -287,6 +282,10 @@ function ProtectedPage() {
|
||||
// retrieve the authenticated user's accessTokenPayload and userId from the sessionContext
|
||||
const { accessTokenPayload, userId } = useSessionContext()
|
||||
|
||||
if (sessionContext.loading === true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const [userEmail, setEmail] = useState('')
|
||||
useEffect(() => {
|
||||
async function getUserEmail() {
|
||||
|
||||
Reference in new issue
Block a user