Hw06 email#4
Conversation
…d API key and configuration.
…ification process.
KamilMr
left a comment
There was a problem hiding this comment.
Hej,
Zadanie zatwierdzam. Zobacz sobie jeszce obsługę błędów w express i uzywanie bloków try catch w zapytaniach synchronicznych i asynchronicznych.
Powodzenia w dalszych etapach.
| avatarURL, | ||
| verificationToken, | ||
| }); | ||
| const verifyEmail = { |
There was a problem hiding this comment.
| const verifyEmail = { | |
| const msgOpt = { |
Zmieniłbym to np na msgOpt lub opt.
| const { email } = req.body; | ||
| const user = await User.findOne({ email }); | ||
| if (!user) { | ||
| throw HttpError(404, "User not found"); |
There was a problem hiding this comment.
Zamiast throw w tych najwyższych ścieżkach trzeba zwrócić błąd użytkownikowi. Bo zastanawiam się co przechwyci ten throw? Jeśli robisz tutaj throw to znaczy że gdzieś wyżej, czyli w miejscu gdzie jest użyta funkcja resendVerifyEmail jest blok catch. Jeśli tego bloku nie ma, to aplikacja przestanie działać.
I to się tyczy wielu miejsc.
| html: `<a target="_blank" href="http://localhost:3000/api/user/verify/${user.verificationToken}">Click verify email</a>`, | ||
| }; | ||
|
|
||
| await sendEmail(verifyEmail); |
There was a problem hiding this comment.
Te najwyższe funkcje async powinny być otoczone w jakimś try catch statement aby obsługiwać błędy które pojawiają się w kodzie.
No description provided.