Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a2b9f248
Unverified
Commit
a2b9f248
authored
May 02, 2020
by
Marko Djordjevic
Committed by
GitHub
May 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 'user undefined' error with ssr profile in auth0 example (#11934)
parent
2e0f52ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
ssr-profile.js
examples/auth0/pages/advanced/ssr-profile.js
+3
-3
No files found.
examples/auth0/pages/advanced/ssr-profile.js
View file @
a2b9f248
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment