You can then invoke the `verifySession()` function in your data requests, Server Actions, Route Handlers:
You can then invoke the `verifySession()` function in your data requests, Server Actions, and Route Handlers:
> **Good to know**: React's [`cache`](https://react.dev/reference/react/cache) deduplicates within a React render pass. Server Actions and Route Handlers are not part of a render pass, so the wrapper does nothing and every call runs the function.
```tsxfilename="app/lib/dal.ts"switcher
exportconstgetUser=cache(async()=>{
...
...
@@ -1316,7 +1322,7 @@ import { verifySession } from '@/app/lib/dal'
exportdefaultasyncfunctionDashboard(){
constsession=awaitverifySession()
constuserRole=session?.user?.role// Assuming 'role' is part of the session object
constuserRole=session?.role// Assuming 'role' is part of the session object
if(userRole==='admin'){
return<AdminDashboard/>
...
...
@@ -1333,7 +1339,7 @@ import { verifySession } from '@/app/lib/dal'
exportdefaultasyncfunctionDashboard(){
constsession=awaitverifySession()
constuserRole=session?.user?.role// Assuming 'role' is part of the session object
constuserRole=session?.role// Assuming 'role' is part of the session object
if(userRole==='admin'){
return<AdminDashboard/>
...
...
@@ -1416,7 +1422,7 @@ import { verifySession } from '@/app/lib/dal'
exportdefaultasyncfunctionAdminActions(){
constsession=awaitverifySession()
constuserRole=session?.user?.role
constuserRole=session?.role
if(userRole!=='admin'){
returnnull
...
...
@@ -1436,7 +1442,7 @@ import { verifySession } from '@/app/lib/dal'
exportdefaultasyncfunctionAdminActions(){
constsession=awaitverifySession()
constuserRole=session?.user?.role
constuserRole=session?.role
if(userRole!=='admin'){
returnnull
...
...
@@ -1470,7 +1476,7 @@ import { verifySession } from '@/app/lib/dal'