var Path    = require("path")
var fs      = require("fs");
var Q       = require("q");

var jsforce = require("jsforce");

function Login( username, password, host ){
  var deferred = Q.defer();
  
  var username = username;
  var password = password;
  var host = host || "login.salesforce.com"

  sfforce.login( username, password, function( result ){
    if(result.error) deferred.reject(result)
    else{
      deferred.resolve( result )
    }
  });

  return deferred.promise; 
}

module.exports = Login;