Skip to content

Commit

Permalink
Escapo consulta noSQL para evitar inyección
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro-C-M committed Apr 30, 2024
1 parent e71be29 commit add759b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion historyservice/guardarDatosUsuarioHistorial.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { escape } from 'validator';

const mongoose = require('mongoose');


const Historial = mongoose.model('historial');

class GuardarDatosUsuarioHistorial{
Expand Down Expand Up @@ -67,7 +70,7 @@ class GuardarDatosUsuarioHistorial{
console.log("Guardado nuevo historial");
}
});
Historial.updateOne({ user: datos.user }, { $inc: { "diariasAcertadas": 1 } }).then(resultado => {
Historial.updateOne({ user: escape(datos.user) }, { $inc: { "diariasAcertadas": 1 } }).then(resultado => {
console.log('Se ha actualizado el ranking diario correctamente o.');
}).catch(error => {
console.error('Error al actualizar el ranking diario:', error);
Expand Down

0 comments on commit add759b

Please sign in to comment.