Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Promise.resolve().then(function() {
if (options.connection) {
conn = jsforce.registry.getConnection(options.connection);
if (!conn) {
throw new Error('No connection named "' + options.connection + '" in registry');
}
} else if (options.username && options.password) {
var config = {};
CONNECTION_CONFIG_PROPS.forEach(function(prop) {
if (options[prop]) { config[prop] = options[prop]; }
});
conn = new jsforce.Connection(config);
return conn.login(options.username, options.password);
} else {
throw new Error(
'Credential to salesforce server is not found in options.\n' +
'Specify "username" and "password" in options.'
);
}