Update example-logged-in-user.mdx (#6780)
Add authenticate() middleware to be able to get current user with req.user
This commit is contained in:
@@ -24,6 +24,7 @@ Create the file `src/api/middlewares.ts` with the following content:
|
|||||||
|
|
||||||
```ts title="src/api/middlewares.ts"
|
```ts title="src/api/middlewares.ts"
|
||||||
import type {
|
import type {
|
||||||
|
authenticate,
|
||||||
MiddlewaresConfig,
|
MiddlewaresConfig,
|
||||||
User,
|
User,
|
||||||
UserService,
|
UserService,
|
||||||
@@ -60,7 +61,7 @@ export const config: MiddlewaresConfig = {
|
|||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
matcher: "/admin/products",
|
matcher: "/admin/products",
|
||||||
middlewares: [registerLoggedInUser],
|
middlewares: [authenticate(), registerLoggedInUser],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user