Permalink
Browse files

fix registration error message

  • Loading branch information...
Jim Snodgrass
Jim Snodgrass committed Apr 5, 2013
1 parent 8784511 commit 458ba32001f35131c7b561622c387082df99dd23
Showing with 8 additions and 1 deletion.
  1. +8 −1 components/user/middleware.js
@@ -45,8 +45,15 @@ module.exports = function(app) {
user.save(function(err) {
if (err) {
var err_message = ((err+"").indexOf("duplicate key error") > -1) ? "That email address is already registered." : err;
+
+ if (err.name == 'ValidationError') {
+ err_message = "Please check the following fields: ";
+ var error_fields = [];
+ _.each(err.errors, function(e) { error_fields.push(e.path); });
+ err_message += error_fields.join(", ");
+ }
+
req.flash(err_message);
- console.log(err);
return res.redirect('/register');
}
else return next();

0 comments on commit 458ba32

Please sign in to comment.