未验证 提交 a2b9f248 编写于 作者: M Marko Djordjevic 提交者: GitHub

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

上级 2e0f52ac
......@@ -21,9 +21,9 @@ export async function getServerSideProps({ req, res }) {
// Here you can check authentication status directly before rendering the page,
// however the page would be a serverless function, which is more expensive and
// 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, {
Location: '/api/login',
})
......@@ -31,7 +31,7 @@ export async function getServerSideProps({ req, res }) {
return
}
return { props: { user } }
return { props: { user: session.user } }
}
export default Profile
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册