Skip to content

Commit

Permalink
Tidy up unique fields from user model
Browse files Browse the repository at this point in the history
  • Loading branch information
simison committed Apr 16, 2015
1 parent 2106e34 commit 7e31b8f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/errors.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Get unique error field name
* @todo: once https://github.com/Automattic/mongoose/issues/2284 gets done, we can have prettier errors for this.
*/
var getUniqueErrorMessage = function(err) {
var output;
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.server.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var UserSchema = new Schema({
email: {
type: String,
trim: true,
unique: 'Email already exists',
unique: true,
lowercase: true,
default: '',
validate: [validateLocalStrategyProperty, 'Please enter your email'],
Expand Down Expand Up @@ -111,7 +111,7 @@ var UserSchema = new Schema({
// Lowercase enforced username
username: {
type: String,
unique: 'Username already exists',
unique: true,
required: 'Please fill in a username',
validate: [validateUsername, 'Please fill in valid username: 3-32 characters long non banned word, characters "_-.", no consecutive dots, lowercase letters a-z and numbers 0-9.'],
lowercase: true, // Stops users creating case sensitive duplicate usernames with "username" and "USERname", via @link https://github.com/meanjs/mean/issues/147
Expand Down

0 comments on commit 7e31b8f

Please sign in to comment.