Skip to content

Commit

Permalink
added alias character check to backend user model
Browse files Browse the repository at this point in the history
  • Loading branch information
abarnhard committed Nov 1, 2014
1 parent 5fca803 commit d6a501f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ User.findById = function(id, cb){

User.register = function(o, cb){
User.collection.find({$or:[{email:o.email},{alias:o.alias}]}).toArray(function(err, users){
if(users.length || o.password.length < 3){return cb();}
var regEx = /^[\w]*$/;
// if user was found, password is less than 3 chars, or alias contains non-alphanumeric chars, break & return
if(users.length || o.password.length < 3 || !o.alias.match(regEx)){return cb();}
o.password = bcrypt.hashSync(o.password, 10);
User.collection.save(o, cb);
});
Expand Down

0 comments on commit d6a501f

Please sign in to comment.