Skip to content

Commit

Permalink
fix: missing update of jwt strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Nov 20, 2022
1 parent 60a03e6 commit ec8aecf
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions packages/medusa-plugin-auth/src/auth-strategies/jwt-override.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
};
};
}

0 comments on commit ec8aecf

Please sign in to comment.