|
1 | 1 | import React from 'react'; |
2 | | -import { getSession, withPageAuthRequired } from '@auth0/nextjs-auth0'; |
| 2 | +import { auth0 } from '../../lib/auth0'; |
3 | 3 |
|
4 | 4 | import Highlight from '../../components/Highlight'; |
5 | 5 |
|
6 | | -export default withPageAuthRequired( |
7 | | - async function SSRPage() { |
8 | | - const { user } = await getSession(); |
9 | | - return ( |
10 | | - <> |
11 | | - <div className="mb-5" data-testid="ssr"> |
12 | | - <h1 data-testid="ssr-title">Server-side Rendered Page</h1> |
13 | | - <div data-testid="ssr-text"> |
14 | | - <p> |
15 | | - You can protect a server-side rendered page by wrapping it with <code>withPageAuthRequired</code>. Only |
16 | | - logged in users will be able to access it. If the user is logged out, they will be redirected to the login |
17 | | - page instead.{' '} |
18 | | - </p> |
19 | | - </div> |
| 6 | +export default async function SSRPage() { |
| 7 | + const { user } = await auth0.getSession(); |
| 8 | + return ( |
| 9 | + <> |
| 10 | + <div className="mb-5" data-testid="ssr"> |
| 11 | + <h1 data-testid="ssr-title">Server-side Rendered Page</h1> |
| 12 | + <div data-testid="ssr-text"> |
| 13 | + <p> |
| 14 | + You can protect a server-side rendered page by wrapping it with <code>withPageAuthRequired</code>. Only |
| 15 | + logged in users will be able to access it. If the user is logged out, they will be redirected to the login |
| 16 | + page instead.{' '} |
| 17 | + </p> |
20 | 18 | </div> |
21 | | - <div className="result-block-container" data-testid="ssr-json"> |
22 | | - <div className="result-block"> |
23 | | - <h6 className="muted">User</h6> |
24 | | - <Highlight>{JSON.stringify(user, null, 2)}</Highlight> |
25 | | - </div> |
| 19 | + </div> |
| 20 | + <div className="result-block-container" data-testid="ssr-json"> |
| 21 | + <div className="result-block"> |
| 22 | + <h6 className="muted">User</h6> |
| 23 | + <Highlight>{JSON.stringify(user, null, 2)}</Highlight> |
26 | 24 | </div> |
27 | | - </> |
28 | | - ); |
29 | | - }, |
30 | | - { returnTo: '/ssr' } |
31 | | -); |
| 25 | + </div> |
| 26 | + </> |
| 27 | + ); |
| 28 | +}; |
0 commit comments