Browse Source

Merge pull request #5043 from nocodb/fix/bcrypt-hash-null-salt

fix(nocodb): prevent from hashing a null salt
pull/5044/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
c8da01c1e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      packages/nocodb/src/lib/meta/api/userApi/initStrategies.ts
  2. 6
      packages/nocodb/src/lib/v1-legacy/gql/GqlAuthResolver.ts
  3. 5
      packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts

7
packages/nocodb/src/lib/meta/api/userApi/initStrategies.ts

@ -207,6 +207,13 @@ export function initStrategies(router): void {
if (!user) {
return done({ msg: `Email ${email} is not registered!` });
}
if (!user.salt) {
return done({
msg: `Please sign up with the invite token first or reset the password by clicking Forgot your password.`,
});
}
const hashedPassword = await promisify(bcrypt.hash)(
password,
user.salt

6
packages/nocodb/src/lib/v1-legacy/gql/GqlAuthResolver.ts

@ -162,7 +162,11 @@ export default class GqlAuthResolver {
if (!user) {
return done({ msg: `Email ${email} is not registered!` });
}
if (!user.salt) {
return done({
msg: `Please sign up with the invite token first or reset the password by clicking Forgot your password.`,
});
}
const hashedPassword = await promisify(bcrypt.hash)(
password,
user.salt

5
packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts

@ -334,6 +334,11 @@ export default class RestAuthCtrl {
if (!user) {
return done({ msg: `Email ${email} is not registered!` });
}
if (!user.salt) {
return done({
msg: `Please sign up with the invite token first or reset the password by clicking Forgot your password.`,
});
}
const hashedPassword = await promisify(bcrypt.hash)(
password,
user.salt

Loading…
Cancel
Save