linnovate/mean — pull request #638 by lirantal (2014-06-30 18:53:22+00:00)
Title: Enhancement validation fixes

Fixed a few issues related to user model validation:

1. Multiple users were able to register with the same e-mail address. I know there's a unique constraint on the username but e-mail is crucial for reasons such as resetting forgotten password, and we're even using the e-mail address as the user's identifier in the login page. I've added a model validation on the user's e-mail field and specifically chosen to do so without the database unique constraint so this can be easily adjusted and serves as an instructional example of how to perform such validations.

2. Errors that the controller's req.assert() didn't catch such as duplicate usernames were not returned correctly to AngularJS which expects an array of error objects with specific attributes. This has been solved to accommodate the original 'username is already taken' validation, as well as the newly introduced unique e-mail address and any future errors returned by the model validation handling.