#Medusa-Extender store auth route

2 messages · Page 1 of 1 (latest)

unborn geyser
#

Hello @fading verge, Thanks a lot for the medusa-extender. This tools is usefull.

I succeed to create an admin route but I didn't find the best solution to create a new Store/xx/me/ route (cookie auth)

My route is accessible without any cookie even if I put the requiredAuth.

@Router({ routes: [{ requiredAuth: true, path: '/store/companies/me', method: 'get',

fading verge
#

Thanks for the kind words. The requiredAuth only register the route after the customer auth middleware. But medusa allows the auth to be optional, to enforce the authentication you need to also apply this middleware before your handler https://github.com/medusajs/medusa/blob/master/packages/medusa/src/api/middlewares/require-customer-authentication.ts if there is a case where you want to enforce the customer auth on multiple routes, in that case, instead of using this middleware on the specific route you can create a middleware using a regexp path (see express docs e.g /store/xx/*) and in that middleware you can call the middleware mentioned above. Alternatively It can also be done by creating first a store/xx/* route and the handler would be the middleware. Hope that it makes sense and help you

GitHub

The open-source Shopify alternative ⚡️. Contribute to medusajs/medusa development by creating an account on GitHub.