server/lib/account/index.js
//Check for well formed message.
Check for well formed message.
Check for well formed message .
function checkMessage(callback) {
    if (req.body.username === null || !req.body.username) {
      res.send(401, "Username is required, please enter a username.");
    } else if (req.body.password === null || !req.body.password) {
      res.send(401, "Password is required, please enter a password.");
    } else if (req.body.email === null || !req.body.email) {
      res.send(401, "Email is required, please enter an email address.");
    } else if (req.body.username.length < 5) {
      res.send(401, "Username must be longer than 5 characters.");
    } else {
      Account.findOne({
        username: req.body.username
      }, function(err, results) {
        if (results) {
          res.send(401, "Username already taken, please select another.");
        } else {
          callback();
        }
      });
    }
  }
function checkMessage ( callback ) { if ( req . body . username === null || ! req . body . username ) { res . send ( 401 , "Username is required, please enter a username." ) ; } else if ( req . body . password === null || ! req . body . password ) { res . send ( 401 , "Password is required, please enter a password." ) ; } else if ( req . body . email === null || ! req . body . email ) { res . send ( 401 , "Email is required, please enter an email address." ) ; } else if ( req . body . username . length < 5 ) { res . send ( 401 , "Username must be longer than 5 characters." ) ; } else { Account . findOne ( { username : req . body . username } , function ( err , results ) { if ( results ) { res . send ( 401 , "Username already taken, please select another." ) ; } else { callback ( ) ; } } ) ; } }
Check for well formed message.
Check for well formed message .