Skip to content

Commit

Permalink
fix: authenticateCustomer method
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Nov 22, 2022
1 parent c7bca61 commit 417c426
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/medusa/src/api/middlewares/authenticate-customer.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { NextFunction, Request, RequestHandler, Response } from "express"
import passport from "passport"

// If authenticated, middleware attaches customer to request (as user)
// If aunauthenticated, we pass through
//
// The implication of the latter case is, that we should throw 401s in the controllers with required customer ids
export default (): RequestHandler => {
return (req: Request, res: Response, next: NextFunction): void => {
passport.authenticate(
["store-jwt", "bearer"],
{ session: false },
(err, user) => {
if (err) {
next(err)
return next(err)
}
req.user = user
return next()
Expand Down

0 comments on commit 417c426

Please sign in to comment.