Skip to content

Commit 83373d9

Browse files
committed
fix: remove bcrypt from webapp, delegate password hashing to back-end
1 parent ff77d14 commit 83373d9

File tree

4 files changed

+5
-54
lines changed

4 files changed

+5
-54
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,11 @@ 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);
1972+
}
1973+
19691974
const newUser = {
19701975
...body,
19711976
StorX: body.StorX || {},

web_app/Source_webapp/package-lock.json

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

web_app/Source_webapp/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@visx/pattern": "^3.0.0",
3636
"apexcharts": "^3.37.3",
3737
"axios": "^1.3.4",
38-
"bcrypt": "^6.0.0",
3938
"blockly": "^10.4.3",
4039
"classnames": "^2.3.2",
4140
"d3-dsv": "^3.0.1",

web_app/Source_webapp/src/utils/hooks/useAuth.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ import { REDIRECT_URL_KEY } from '@/constants/app.constant'
1212
import { useNavigate } from 'react-router-dom'
1313
import useQuery from './useQuery'
1414
import type { SignInCredential, SignUpCredential } from '@/@types/auth'
15-
import * as bcrypt from 'bcrypt'
1615

1716
type Status = 'success' | 'failed'
1817

1918
function useAuth() {
2019
const dispatch = useAppDispatch()
21-
const saltRounds = parseInt(process.env.CRYPTION_SALT || '10', 10)
2220
const navigate = useNavigate()
2321

2422
const query = useQuery()
@@ -37,14 +35,6 @@ function useAuth() {
3735
try {
3836
let resp
3937

40-
const salt = bcrypt.genSaltSync(saltRounds)
41-
const hashedNewPassword = bcrypt.hashSync(
42-
String(values.password),
43-
salt
44-
)
45-
46-
values = { ...values, password: hashedNewPassword }
47-
4838
if (values.tokenId || values.accessToken) {
4939
try {
5040
resp = await apiSignInGoogle(
@@ -98,14 +88,6 @@ function useAuth() {
9888

9989
const signUp = async (values: SignUpCredential) => {
10090
try {
101-
const salt = bcrypt.genSaltSync(saltRounds)
102-
const hashedNewPassword = bcrypt.hashSync(
103-
String(values.password),
104-
salt
105-
)
106-
107-
values = { ...values, password: hashedNewPassword }
108-
10991
const resp = await apiSignUp(values)
11092
console.log(resp)
11193
if (resp.data) {

0 commit comments

Comments
 (0)