Unverified Commit a2b9f248 authored by Marko Djordjevic's avatar Marko Djordjevic Committed by GitHub

Fix 'user undefined' error with ssr profile in auth0 example (#11934)

parent 2e0f52ac
...@@ -21,9 +21,9 @@ export async function getServerSideProps({ req, res }) { ...@@ -21,9 +21,9 @@ export async function getServerSideProps({ req, res }) {
// Here you can check authentication status directly before rendering the page, // Here you can check authentication status directly before rendering the page,
// however the page would be a serverless function, which is more expensive and // however the page would be a serverless function, which is more expensive and
// slower than a static page with client side authentication // slower than a static page with client side authentication
const { user } = await auth0.getSession(req) const session = await auth0.getSession(req)
if (!user) { if (!session || !session.user) {
res.writeHead(302, { res.writeHead(302, {
Location: '/api/login', Location: '/api/login',
}) })
...@@ -31,7 +31,7 @@ export async function getServerSideProps({ req, res }) { ...@@ -31,7 +31,7 @@ export async function getServerSideProps({ req, res }) {
return return
} }
return { props: { user } } return { props: { user: session.user } }
} }
export default Profile export default Profile
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