mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-06 03:55:30 +02:00
fix(core): Add custom 400 and 404 error messages (#1547)
* Added 400 and 404 custom error messages * nicer error message views * Sign Up & Sign In error responses 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: https://github.com/meanjs/mean/pull/1510#issuecomment-247435378 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
This commit is contained in:
@@ -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 {
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user