Quellcode durchsuchen

fixed error check in addedwords for shelf, changed error messages

master
kj1352 vor 4 Jahren
Ursprung
Commit
efe4112dc8
1 geänderte Dateien mit 5 neuen und 5 gelöschten Zeilen
  1. +5
    -5
      src/user-profile/shelf-routes.ts

+ 5
- 5
src/user-profile/shelf-routes.ts Datei anzeigen

@@ -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;
}
}


Laden…
Abbrechen
Speichern