GithubHelp home page GithubHelp logo

Comments (9)

uladaharanina avatar uladaharanina commented on June 26, 2024

Hi, I believe we need to do this:

const requireSignin = () => expressJwt({
secret: config.jwtSecret,
userProperty: 'auth'
});

And in the user.routes.js apply () to requireSignin.

router.route('/api/users/:userId')
.get(authCtrl.requireSignin(), userCtrl.read)
.put(authCtrl.requireSignin(), authCtrl.hasAuthorization, userCtrl.update)
.delete(authCtrl.requireSignin(), authCtrl.hasAuthorization, userCtrl.remove)

from full-stack-react-projects-second-edition.

shruthis-shetty avatar shruthis-shetty commented on June 26, 2024

Hi @inatu , did you got the solution to this issue or still having any issues?
Please reply here the update.

from full-stack-react-projects-second-edition.

JimmyJoggins avatar JimmyJoggins commented on June 26, 2024

With "express-jwt": "^8.4.1"

Try adding algorithms as follows:

const requireSignin = expressJwt({
secret: config.jwtSecret,
userProperty: 'auth',
algorithms: ["HS256"]
})

The above approach worked for me. No need to convert authCtrl.requireSignin to a function.

from full-stack-react-projects-second-edition.

shruthis-shetty avatar shruthis-shetty commented on June 26, 2024

Hi @inatu , @JimmyJoggins and @wadewilsones , anyone of you please confirm me whether we are good to close this issue?

from full-stack-react-projects-second-edition.

JimmyJoggins avatar JimmyJoggins commented on June 26, 2024

Given the level of inactivity, I think probably yes.

from full-stack-react-projects-second-edition.

Apurv-Salunke avatar Apurv-Salunke commented on June 26, 2024

@inatu I am getting the exact same error. How did you resolve it ?

from full-stack-react-projects-second-edition.

Apurv-Salunke avatar Apurv-Salunke commented on June 26, 2024

webpack:///./server/controllers/auth.controller.js?:54
const requireSignin = express_jwt__WEBPACK_IMPORTED_MODULE_2___default()({
^

TypeError: express_jwt__WEBPACK_IMPORTED_MODULE_2___default(...) is not a function
at eval (webpack:///./server/controllers/auth.controller.js?:54:73)
at ./server/controllers/auth.controller.js (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:29:1)
at webpack_require (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:233:41)
at eval (webpack:///./server/routes/user.routes.js?:8:86)
at ./server/routes/user.routes.js (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:89:1)
at webpack_require (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:233:41)
at eval (webpack:///./server/express.js?:18:77)
at ./server/express.js (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:49:1)
at webpack_require (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:233:41)
at eval (webpack:///./server/server.js?:3:66)

Node.js v18.16.0

from full-stack-react-projects-second-edition.

oriankeith002 avatar oriankeith002 commented on June 26, 2024

webpack:///./server/controllers/auth.controller.js?:54 const requireSignin = express_jwt__WEBPACK_IMPORTED_MODULE_2___default()({ ^

TypeError: express_jwt__WEBPACK_IMPORTED_MODULE_2___default(...) is not a function at eval (webpack:///./server/controllers/auth.controller.js?:54:73) at ./server/controllers/auth.controller.js (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:29:1) at webpack_require (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:233:41) at eval (webpack:///./server/routes/user.routes.js?:8:86) at ./server/routes/user.routes.js (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:89:1) at webpack_require (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:233:41) at eval (webpack:///./server/express.js?:18:77) at ./server/express.js (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:49:1) at webpack_require (/media/apurv/work space/academic projects/mern-stack/social-media/dist/server.generated.js:233:41) at eval (webpack:///./server/server.js?:3:66)

Node.js v18.16.0

Hi, import express jwt with a different syntaxt

from full-stack-react-projects-second-edition.

oriankeith002 avatar oriankeith002 commented on June 26, 2024

let { expressjwt: expressJwt } = require('express-jwt');

from full-stack-react-projects-second-edition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.