Skip to content

Commit 487daa6

Browse files
committed
fix: error while hashing password
1 parent 83373d9 commit 487daa6

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

backend/src/modules/user/services/user/user.service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
import { MailService } from 'src/modules/utility/services/mail.service';
3737
import { randomBytes } from 'crypto';
3838

39-
const saltRounds = process.env.CRYPTION_SALT;
39+
const saltRounds = parseInt(process.env.CRYPTION_SALT) || 10;
4040

4141
/**
4242
* User manipulation service.
@@ -1966,9 +1966,8 @@ export class UserService {
19661966
roles.push(ordinaryUserRole);
19671967
}
19681968

1969-
if (body.password){
1970-
const salt = bcrypt.genSaltSync(saltRounds);
1971-
body.password = bcrypt.hashSync(String(body.password), salt);
1969+
if (body.password) {
1970+
body.password = await bcrypt.hash(String(body.password), saltRounds);
19721971
}
19731972

19741973
const newUser = {

package-lock.json

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"devDependencies": {
3+
"@types/bcrypt": "^6.0.0"
4+
}
5+
}

0 commit comments

Comments
 (0)