Unverified Commit 9c5fa27c authored by Wes's avatar Wes Committed by GitHub

docs: change Dashboard component to async for session verification (#81880)

## Improving Documentation

Updated the `Dashboard` component to be an `async` function to properly
`await` the session verification process. This change ensures that the
user role is retrieved correctly from `session` before rendering the
component.
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent 42bcacd9
...@@ -1312,7 +1312,7 @@ Auth check in [Server Components](/docs/app/getting-started/server-and-client-co ...@@ -1312,7 +1312,7 @@ Auth check in [Server Components](/docs/app/getting-started/server-and-client-co
```tsx filename="app/dashboard/page.tsx" switcher ```tsx filename="app/dashboard/page.tsx" switcher
import { verifySession } from '@/app/lib/dal' import { verifySession } from '@/app/lib/dal'
export default function Dashboard() { export default async function Dashboard() {
const session = await verifySession() const session = await verifySession()
const userRole = session?.user?.role // Assuming 'role' is part of the session object const userRole = session?.user?.role // Assuming 'role' is part of the session object
...@@ -1329,9 +1329,9 @@ export default function Dashboard() { ...@@ -1329,9 +1329,9 @@ export default function Dashboard() {
```jsx filename="app/dashboard/page.jsx" switcher ```jsx filename="app/dashboard/page.jsx" switcher
import { verifySession } from '@/app/lib/dal' import { verifySession } from '@/app/lib/dal'
export default function Dashboard() { export default async function Dashboard() {
const session = await verifySession() const session = await verifySession()
const userRole = session.role // Assuming 'role' is part of the session object const userRole = session?.user?.role // Assuming 'role' is part of the session object
if (userRole === 'admin') { if (userRole === 'admin') {
return <AdminDashboard /> return <AdminDashboard />
......
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