Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #308

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2516b89
Merge pull request #303 from Arquisoft/master
uo282189 Apr 29, 2024
4184387
Merge pull request #304 from Arquisoft/master
uo282189 Apr 29, 2024
a4cd064
Merge pull request #305 from Arquisoft/develop
uo282189 Apr 29, 2024
dd501ba
actualizado color modo claro
uo282189 Apr 29, 2024
c547a72
añadida internacionalizacion en rankingRoom
uo282189 Apr 29, 2024
42781fc
actualizado mensaje inicial
uo282189 Apr 29, 2024
0bf6c8a
añadida una pequeña auida
uo282189 Apr 29, 2024
8657256
añadido test de la ayuda
uo282189 Apr 29, 2024
d2f2ebf
actualizado test principalViwe
uo282189 Apr 29, 2024
42eaf99
actualizado principal view
uo282189 Apr 29, 2024
24292c3
actualizado test ranking
uo282189 Apr 29, 2024
68e7c0d
Merge pull request #306 from Arquisoft/sonia
bidof Apr 29, 2024
4d7a786
Arreglo incremento diarias para ranking
Pedro-C-M Apr 30, 2024
d1518f9
Ligo con el acierto la suma para el ranking
Pedro-C-M Apr 30, 2024
6572e96
Fuera consoles y estructuras para depuraciones
Pedro-C-M Apr 30, 2024
712cb36
Adaptado para ranking de int en vez de String
Pedro-C-M Apr 30, 2024
686255c
Cambiando test para pasar
Pedro-C-M Apr 30, 2024
e71be29
Sigo arreglando test de ranking
Pedro-C-M Apr 30, 2024
add759b
Escapo consulta noSQL para evitar inyección
Pedro-C-M Apr 30, 2024
12314b9
Quito libreria escape
Pedro-C-M Apr 30, 2024
14472a4
Sigo intentando evitar inyeccion
Pedro-C-M Apr 30, 2024
b838d94
Validando inputs
Pedro-C-M Apr 30, 2024
78173db
Falla tests con la inyeccion quitada
Pedro-C-M Apr 30, 2024
4dc9699
Continuo test
Pedro-C-M Apr 30, 2024
9c5c9f3
Merge pull request #307 from Arquisoft/PedroFixingRanking
bidof Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions historyservice/guardarDatosUsuarioHistorial.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const mongoose = require('mongoose');


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

class GuardarDatosUsuarioHistorial{
Expand Down Expand Up @@ -60,24 +61,31 @@
// Si no existe historial para ese usuario lo crea
var nuevoHistorial = new Historial({
user: datos.user,
diariasAcertadas:1
diariasAcertadas:0
});
//Guardamos el nuevo historial
nuevoHistorial.save();
console.log("Guardado nuevo historial");
}

else{
usuarioExistente.diariasAcertadas++;
usuarioExistente.save();
console.log("Guardado historial");
}

});
});
let inputBD = datos.user;
if (validarInput(inputBD)) {
Historial.updateOne({ user: inputBD }, { $inc: { "diariasAcertadas": 1 } }).then(resultado => {

Check failure

Code scanning / SonarCloud

NoSQL operations should not be vulnerable to injection attacks High

Change this code to not construct database queries directly from user-controlled data. See more on SonarCloud
console.log('Se ha actualizado el ranking diario correctamente o.');
}).catch(error => {
console.error('Error al actualizar el ranking diario:', error);
});
}else{
console.error('Error al actualizar el ranking diario, mal validado.');
}
}
}

function validarInput(user) {
if (!user) {
return false;
}
return true;
}

module.exports = GuardarDatosUsuarioHistorial;
5 changes: 5 additions & 0 deletions historyservice/history-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const historySchema = new mongoose.Schema({
type: String,
required: true
},

diariasAcertadas: {
type: Number,
required: true
},

juegos: [{
numeroJuego: {
Expand Down
1 change: 1 addition & 0 deletions historyservice/obtenerDetallesUsuarioBaseDatos.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class History{
async obtenerPreguntasDiariasAcertadas(){
console.log("entra en obtenerPreguntasDiariasAcertadas");
//Ranking de usuarios ordenado por número de preguntas diarias acertadas
//debería con esto funcionar tambien para ints
var rankingUsuarios = await Historial.find({}, "user diariasAcertadas").sort({diariasAcertadas: -1});
console.log(rankingUsuarios);
//Y lo devolvemos
Expand Down
58 changes: 0 additions & 58 deletions webapp/gatewayservice/package-lock.json

This file was deleted.

5 changes: 0 additions & 5 deletions webapp/gatewayservice/package.json

This file was deleted.

58 changes: 0 additions & 58 deletions webapp/historyservice/package-lock.json

This file was deleted.

5 changes: 0 additions & 5 deletions webapp/historyservice/package.json

This file was deleted.

58 changes: 0 additions & 58 deletions webapp/questionservice/package-lock.json

This file was deleted.

5 changes: 0 additions & 5 deletions webapp/questionservice/package.json

This file was deleted.

58 changes: 0 additions & 58 deletions webapp/roomservice/package-lock.json

This file was deleted.

5 changes: 0 additions & 5 deletions webapp/roomservice/package.json

This file was deleted.

10 changes: 10 additions & 0 deletions webapp/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import BasicGame from './components/game/BasicGame';
import DailyGameMode from './components/game/gameModes/DailyGameMode';
import CategoriesWindow from './components/categories/Categories';

import HelpView from './components/help/HelpView';


const App = () => {

const [darkMode, setDarkMode] = useState(false);
Expand Down Expand Up @@ -73,6 +76,13 @@ const App = () => {
<Home />
</AuthenticatedLayout>
} />

<Route path="/help" element={
<ChakraProvider>
<HelpView darkMode={darkMode}/>
</ChakraProvider>
} />

<Route path="/game" element={
<AuthenticatedLayout>
<ChakraProvider><Game darkMode={darkMode} gameMode={new BasicGame()}/> </ChakraProvider>
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/components/adduser/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const AddUser = (darkMode) => {
setOpenSnackbar(false);
};

let backgroundColor = darkMode.darkMode ? '#001c17' : '#fef5c6';
let text = darkMode.darkMode ? '#FCFAF0' : '#08313A';
let buttonColor = darkMode.darkMode ? '#107869' : '#FFFFF5';
let backgroundColor = darkMode.darkMode ? '#001c17' : '#37BEB0';
let text = darkMode.darkMode ? '#FCFAF0' : '#071815';
let buttonColor = darkMode.darkMode ? '#107869' : '#A4E5E0';

//para la internacionalización
const {t} = useTranslation();
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/components/categories/Categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const CategoriesWindow = () => {
id="button-category-art"
onClick={handleClickArt}
margin="2em"
colorScheme='green' variant='solid'
colorScheme='red' variant='solid'
>
{t('categoryArt')}
</Button>
Expand Down Expand Up @@ -105,6 +105,7 @@ const CategoriesWindow = () => {
id="button-category-entertainment"
onClick={handleClickEntertainment}
margin="2em"
colorScheme='pink' variant='solid'
>
{t('categoryEntertainment')}
</Button>
Expand All @@ -122,7 +123,7 @@ const CategoriesWindow = () => {
id="button-category-history"
onClick={handleClickHistory}
margin="2em"
colorScheme='teal' variant='solid'
colorScheme='purple' variant='solid'
>
{t('categoryHistory')}
</Button>
Expand Down
Loading