code: function(credentials){
        var socialLogin = false;
        if (credentials == undefined){
          credentials = {
            userid: $('#login_email').val(),
            password: $('#login_password').val()
          };
        } else if (typeof credentials === 'string'){
          socialLogin = true;
        }
  
        // Alter the UI to indicate that the login request is pending
        $('#login_button').attr('value', 'Logging in...');
        $('#register_button, #or').hide();
  
        var login = socialLogin ? cm.loginSocial.bind(cm) : cm.login.bind(cm);
  
        function loginError(msg){
          $('#login_button').attr('value', 'Login');
          $('#register_button, #or').show();
          todo.error('login', msg);
        }
  
        // Run CloudMine login request.
        login(credentials)
          .on('success', function(data){
            var services = data.profile.__services__;
            if(services){
              console.log("linked services:", services);
              data.profile.__services__.forEach(function(service){
                $('a.auth.' + service).hide();
              });
            }
            todo.process_login(data);
          })
          .on('unauthorized', function(data){
            loginError(data.errors[0]);
          })
          .on('error', function(data){
            loginError(data.errors ? data.errors[0] : "Error Logging in");
          })
      }
docs: /*
  login_user
  
  Called by Login button click and todo.process_registration (new user is immediately logged in after registration)
  Parameter:
  credentials: optional object containing username and password