DEV Community

Discussion on: Password authentication

Collapse
 
nathanbarrett profile image
Nathan Barrett

nice! looks great! i like how you went with the early returns inside of each if statement instead of doing if->else if->else. this is called the "Return Early" method and it is much preferred over "else" statements in most circumstances and you successfully implemented it! ( forum.freecodecamp.org/t/the-retur... ).
also, in the future you will also probably run into http status codes and how they help others that use the endpoints that you create ( httpstatuses.com/ ). so if you get the error you could also return res.status(500).send('there was an error') . and if the password doesn't match you could res.status(401).send('Wrong Password'). 200 is the main "all good" status code but anything in the 200s is considered a "good" response (or "accepted" may be a better word).

Collapse
 
mtee profile image
Margaret W.N

Thank you Nathan.

I'll go through the resources and familiarize myself with the http status codes.