node-js-jwt-auth-mongodb icon indicating copy to clipboard operation
node-js-jwt-auth-mongodb copied to clipboard

getting a bcrypt error

Open Knighton910 opened this issue 5 years ago • 2 comments

I forked your code and ran npm install. Im running into this issue: Error: Illegal arguments: undefined, string

(method:Post) localhost:8080/api/auth/signup

Error: Illegal arguments: undefined, string at Object.bcrypt.hashSync (/Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/bcryptjs/dist/bcrypt.js:189:19) at exports.signup (/Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/app/controllers/auth.controller.js:13:22) at Layer.handle [as handle_request] (/Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/express/lib/router/layer.js:95:5) at next (/Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/express/lib/router/route.js:137:13) at checkRolesExisted (/Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/app/middlewares/verifySignUp.js:51:3) at Layer.handle [as handle_request] (/Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/express/lib/router/layer.js:95:5) at next (/Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/express/lib/router/route.js:137:13) at /Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/app/middlewares/verifySignUp.js:34:7 at /Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/mongoose/lib/model.js:4915:16 at /Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/mongoose/lib/helpers/promiseOrCallback.js:24:16 at /Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/mongoose/lib/model.js:4938:21 at /Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/mongoose/lib/query.js:4380:11 at /Users/lordknighton/Desktop/node-js-jwt-auth-mongodb/node_modules/kareem/index.js:135:16 at processTicksAndRejections (internal/process/task_queues.js:79:11)

Knighton910 avatar May 21 '20 18:05 Knighton910

Hello Knighton910! I have recently ran into this issue and have found out what was going on. Make sure you're not submitting the POST request in the wrong format through Postman. Be sure to select JSON if you're testing it as Bezkoder does in the tutorial.

Very easy fix, best of luck to you!

ghost avatar Jul 06 '20 23:07 ghost

Hello @Knighton910 I run the npm install commond. But i did not got any issue.

C:\Users\pkv\Desktop\krishna\node-js-jwt-auth-mongodb> npm install

added 193 packages, and audited 194 packages in 2m

16 packages are looking for funding run npm fund for details

found 0 vulnerabilities PS C:\Users\pkv\Desktop\krishna\node-js-jwt-auth-mongodb> node server.js (node:20260) [MONGOOSE] DeprecationWarning: Mongoose: the strictQuery option will be switched back to false by default in Mongoose 7. Use mongoose.set('strictQuery', false); if you want to prepare for this change. Or use mongoose.set('strictQuery', true); to suppress this warning. (Use node --trace-deprecation ... to show where the warning was created) Server is running on port 8080. Successfully connect to MongoDB. added 'user' to roles collection added 'admin' to roles collection added 'moderator' to roles collection

krishna020 avatar Feb 02 '24 11:02 krishna020