Skip to content

Commit

Permalink
feat: store hash password using bcrypt (foyzulkarim#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
aninda052 committed Aug 29, 2023
1 parent 94fdd18 commit 1f22030
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"@ffprobe-installer/ffprobe": "^2.1.1",
"bcrypt": "^5.1.0",
"bcrypt": "^5.1.1",
"bullmq": "^3.5.11",
"compression": "^1.7.4",
"cors": "^2.8.5",
Expand Down
8 changes: 7 additions & 1 deletion server/src/modules/models/user/controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { User } = require('../../db/collections');
const { validate } = require('./request');
const bcrypt = require('bcrypt')

const BASE_URL = `/api/user`;

Expand All @@ -11,7 +12,12 @@ const setupRoutes = (app) => {
const validationResult = validate(req.body);

if (!validationResult.error) {
const result = await User.insert({isActive:true, ...validationResult.value});
const hashPassword = await bcrypt.hash(req.body.password, 10)
const result = await User.insert({
isActive:true,
...validationResult.value,
password: hashPassword
});
if (result instanceof Error) {
return res.status(400).json(result.message);
}
Expand Down

0 comments on commit 1f22030

Please sign in to comment.