Sfoglia il codice sorgente

fixed error check in addedwords for shelf, changed error messages

master
kj1352 4 anni fa
parent
commit
efe4112dc8
1 ha cambiato i file con 5 aggiunte e 5 eliminazioni
  1. +5
    -5
      src/user-profile/shelf-routes.ts

+ 5
- 5
src/user-profile/shelf-routes.ts Vedi File

@@ -120,23 +120,23 @@ shelfRoutes.put('/update/', jwtAuthentication, async (request, response) => {

for (let i = 0; i < updatedAddedWords.length; i += 1) {
if (!updatedAddedWords[i].word || !updatedAddedWords[i].isArchived ||
!updatedAddedWords[i].isFavourite || !updatedAddedWords[i].nextRevisionDateTime ||
!updatedAddedWords[i].notes || !updatedAddedWords[i].revisionHistory || !updatedAddedWords[i].spaceBetweenRecall) {
if (!updatedAddedWords[i].word || updatedAddedWords[i].isArchived === undefined ||
updatedAddedWords[i].isFavourite === undefined || !updatedAddedWords[i].nextRevisionDateTime ||
updatedAddedWords[i].notes === undefined || updatedAddedWords[i].revisionHistory === undefined ||
!updatedAddedWords[i].spaceBetweenRecall) {
response.status(400);
response.send("Missing key in " + JSON.stringify(updatedAddedWords[i]));
return;
}

const wordId = updatedAddedWords[i].word;
const matchedWord = await wordCollection.findOne({
_id: new ObjectId(wordId)
});

if (!matchedWord) {
response.status(400);
response.send("Word with ID " + updatedAddedWords[i] + " is not present in the library" );
response.send("Word with ID " + updatedAddedWords[i].word + " is not present in the library" );
return;
}
}


Caricamento…
Annulla
Salva