title: Node.js login/register Redis problems
body: <pre><code>};
  var login = function(name, socket, passcode, callback) { 
      db.get(name + ':name', function(res) {
          db.get(name + ':pin', function(pin) {
              if (name === res) {
                  if (passcode === pin) {
                      players[sockets.indexOf(socket)] = name;
                  }
              }
          });
      });
  };
  var register = function(name, socket, passcode, callback) {
      if (name === null) {
          callback('Name null!');
          return;
      }
      if (name === '') {
          callback('Name empty!');
          return;
      }
      db.get(name + ':name', function(data) {
          if (data !== null) {
          callback('This name has been taken!');
      }
      else {
          db.set(name + ':name', name, function() {
              db.set(name + ':pin', passcode, function() {
                  players[sockets.indexOf(socket)] = name;
                  callback('Logged in as: ' + players[sockets.indexOf(socket)]);
              });
          });
      }
  });
  };
  </code></pre>
  
  <p>Why does the login part let me login with any PIN to any user, and the register part not callback?</p>
  
  <p>They are called via </p>
  
  <pre><code>   login(args[1], socket, args[2], function(data) {
          callback(null, data)
      }
  </code></pre>
  
  <p>db is a redis client.</p>
  
  <p>Full code: github.com/creativemud, file server.js</p>