Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Sign Up & Sign In error responses
Browse files Browse the repository at this point in the history
Changed the error responses returned from the Sign Up & Sign In API
calls to use 422 rather than 400.

For insight into why this change was made:
#1510 (comment)

For reference on why to use 422 over 400:
https://www.bennadel.com/blog/2434-http-status-codes-for-invalid-data-400-vs-422.htm
  • Loading branch information
mleanos committed Oct 7, 2016
1 parent 563b4f5 commit 6cff0d0
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.signup = function (req, res) {
// Then save the user
user.save(function (err) {
if (err) {
return res.status(400).send({
return res.status(422).send({
message: errorHandler.getErrorMessage(err)
});
} else {
Expand All @@ -55,7 +55,7 @@ exports.signup = function (req, res) {
exports.signin = function (req, res, next) {
passport.authenticate('local', function (err, user, info) {
if (err || !user) {
res.status(400).send(info);
res.status(422).send(info);
} else {
// Remove sensitive data before login
user.password = undefined;
Expand Down

0 comments on commit 6cff0d0

Please sign in to comment.