Comments (9)
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.
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.
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.
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.
Given the level of inactivity, I think probably yes.
from full-stack-react-projects-second-edition.
@inatu I am getting the exact same error. How did you resolve it ?
from full-stack-react-projects-second-edition.
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.
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.
let { expressjwt: expressJwt } = require('express-jwt');
from full-stack-react-projects-second-edition.
Related Issues (20)
- I still see the MERN Scheleton title, even though I have entered all the code from chapter 5, instead of MERN Social title HOT 1
- How can i test callback oauth from stripe using https protocol in development HOT 1
- Unable to run the client and the server (Chapter 8)
- SOLVED_____________chapter 7 - {"error":"Error: Material-UI: capitalize(string) expects a string argument."} HOT 2
- Hi How to add favicon to mern-skeleton?
- Build Successful no errors but no output Chapter 3 and 4 mern-skeleton HOT 4
- How to Deploy
- Private Route
- supported options connect mongoose
- Issue in the server.js file mongoose.connect code HOT 3
- How to deploy?
- Routing in client HOT 1
- Chapter 3 and Chapter 4 Mern skeleton user.model.js need set email field with unique: true?
- Rendering a home page view HOT 6
- Unable to Run Chap3 Skeleton HOT 1
- Webpack Eval() error HOT 2
- Cannot edit profile in MERN Classroom Ch 6
- Cant Create user in Chapter 3 and 4 HOT 1
- After using server-side rendering, I always got warning in console
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from full-stack-react-projects-second-edition.