Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
Mi hash bcrypt.js devuelve indefinido mientras que todas las demás entradas están bien

Este código a continuación devuelve la contraseña de entrada como indefinida, pero todas las demás entradas están bien. No sé qué hacer, si alguien puede ayudar, por favor.

Estoy usando bcrypt.js con knex para psql.

 app.post("/register", (req, res) => { const { email, name, password } = req.body; let salt = bcrypt.genSaltSync(10); let hash = bcrypt.hashSync(password, salt); knex .transaction((trx) => { trx .insert({ hash: bcrypt.hashSync(password, salt), email: email, }) .into("login") .returning("email") .then((loginEmail) => { return trx("users") .returning("*") .insert({ email: loginEmail[0].email, name: name, joined: new Date(), }) .then((user) => { res.json(user[0]); }); }) .then(trx.commit) .catch(trx.rollback); }) .catch((err) => res.status(400).json("E-mail is already in use")); });

*PD Usar cartero no da errores. El error que aparece en el terminal de back-end es Error: Illegal arguments: undefined, string que significa que hash no está definido

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Lo arreglé, aparentemente era un problema de nomenclatura variable :) una tontería.

la contraseña en realidad se recibía como "hash" desde el front-end, la cambió a hash y cambió el hash a hashPassword.

 const { email, name, hash } = req.body; let salt = bcrypt.genSaltSync(10); let hashedPassword = bcrypt.hashSync(hash, salt); knex .transaction((trx) => { trx .insert({ hash: hashedPassword, email: email, })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!