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

220
Views
cómo anular la selección de alguna parte de los datos del objeto para que no aparezcan en respuesta

En mi proyecto my mern, cuando el usuario inicia sesión en la respuesta, mi servidor le envía la respuesta con contraseña hash y restablece el token de contraseña, ¿hay alguna forma de solucionarlo?

ingrese la descripción de la imagen aquí

Aquí está mi modelo de usuario

 const mongoose = require("mongoose"); const validator = require("validator"); const bcrypt = require("bcryptjs"); const crypto = require("crypto") const jwt = require("jsonwebtoken"); const userSchema = new mongoose.Schema({ name: { type: String, required: [true, "please Ente the your name"], }, email: { type: String, required: [true, "Please Enter the email"], unique: [true], validate: [validator.isEmail, "Please Enter a valid email"], }, password: { type: String, required: true, minlength: [8, "Passwaord must be more that 8 characters"], select: false, }, avatar: { public_id: { type: String, required: true, }, url: { type: String, required: true, }, }, role: { type: String, default: "user", }, resetPasswordToken: String, resetPasswordExpire: Date, createdAt: { type: Date, default: Date.now, }, }); userSchema.pre("save", async function (next) { if (!this.isModified("password")) { next(); } this.password = await bcrypt.hash(this.password, 10); }); userSchema.methods.comparePassword = async function (password) { return await bcrypt.compare(password, this.password); }; userSchema.methods.getJWTToken = function () { return jwt.sign({ id: this._id }, process.env.JWT_SECRET, { expiresIn: process.env.JWT_EXPIRE, }); }; // compare password // userSchema.methods.comparePassword = async function(enterPass){ // return await bcyrypt.compare(enterPass,this.password) // } // Reset Password userSchema.methods.getResetPasswordToken = function () { // Generating Token const resetToken = crypto.randomBytes(20).toString("hex"); // Hashing and adding resetPasswordToken to userSchema this.resetPasswordToken = crypto .createHash("sha256") .update(resetToken) .digest("hex"); this.resetPasswordExpire = Date.now() + 15 * 60 * 1000; return resetToken; }; module.exports = mongoose.model("User", userSchema);

como sugiero que ya he usado seleccionar falso y también selecciono restablecer token de contraseña Recibo un error cuando intento devolver cualquier cosa excepto el usuario

about 4 years ago · Juan Pablo Isaza
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!