From ec8aecfe63024236674049563518f4b4365680d2 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Sun, 20 Nov 2022 13:23:34 +0100 Subject: [PATCH] fix: missing update of jwt strategy --- .../src/auth-strategies/jwt-override.ts | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/packages/medusa-plugin-auth/src/auth-strategies/jwt-override.ts b/packages/medusa-plugin-auth/src/auth-strategies/jwt-override.ts index 50057fd..7d3f2a6 100644 --- a/packages/medusa-plugin-auth/src/auth-strategies/jwt-override.ts +++ b/packages/medusa-plugin-auth/src/auth-strategies/jwt-override.ts @@ -6,7 +6,7 @@ import { AUTH_TOKEN_COOKIE_NAME } from '../types'; export function loadJwtOverrideStrategy(configModule: ConfigModule): void { const { jwt_secret } = configModule.projectConfig; passport.use( - 'jwt.medusa-plugin-auth', + 'jwt', new JWTStrategy( { jwtFromRequest: (req) => req.cookies[AUTH_TOKEN_COOKIE_NAME] ?? req.session.jwt, @@ -17,22 +17,4 @@ export function loadJwtOverrideStrategy(configModule: ConfigModule): void { } ) ); - - const middlewares = require('@medusajs/medusa/dist/api/middlewares/index'); - middlewares.default.authenticate = () => { - return (req, res, next) => { - passport.authenticate(['jwt.medusa-plugin-auth', 'bearer'], { session: false })(req, res, next); - }; - }; - middlewares.default.authenticateCustomer = () => { - return (req, res, next) => { - passport.authenticate(['jwt.medusa-plugin-auth', 'bearer'], { session: false }, (err, user) => { - if (err) { - return next(err); - } - req.user = user; - return next(); - })(req, res, next); - }; - }; }