docs: fix import of authenticate middleware (#4572)
* docs: fix import of authenticate middleware * fix eslint errors
This commit is contained in:
@@ -157,21 +157,22 @@ Protected routes are routes that should be accessible by logged-in customers or
|
|||||||
|
|
||||||
### Protect Store Routes
|
### Protect Store Routes
|
||||||
|
|
||||||
To make a storefront route protected, first, import the `authenticate-customer` middleware:
|
To make a storefront route protected, first, import the `authenticateCustomer` middleware:
|
||||||
|
|
||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import
|
import { authenticateCustomer } from "@medusajs/medusa"
|
||||||
authenticate
|
|
||||||
from "@medusajs/medusa/dist/api/middlewares/authenticate-customer"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, add the middleware to your route:
|
Then, add the middleware to your route:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
router.options("/store/hello", cors(corsOptions))
|
router.options("/store/hello", cors(corsOptions))
|
||||||
router.get("/store/hello", cors(corsOptions), authenticate(),
|
router.get(
|
||||||
|
"/store/hello",
|
||||||
|
cors(corsOptions),
|
||||||
|
authenticateCustomer(),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
// user is logged in
|
// user is logged in
|
||||||
@@ -193,9 +194,7 @@ To make an admin route protected, first, import the `authenticate` middleware:
|
|||||||
<!-- eslint-disable max-len -->
|
<!-- eslint-disable max-len -->
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import
|
import { authenticate } from "@medusajs/medusa"
|
||||||
authenticate
|
|
||||||
from "@medusajs/medusa/dist/api/middlewares/authenticate"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, add the middleware to your route:
|
Then, add the middleware to your route:
|
||||||
|
|||||||
Reference in New Issue
Block a user