diff --git a/lib/cli.js b/lib/cli.js index 76a3ae60..96d41f62 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -347,7 +347,7 @@ CLI.prototype.login = function login(next) { // and password, or show an error message if (this.command.requireAuth && !appc.auth.status().loggedIn) { var argv = this.argv, - proxy = this.config.cli.httpProxyServer, + proxy = this.config.get('cli.httpProxyServer'), logger = this.logger, attempts = 1, prompt = function prompt(err) { @@ -394,19 +394,25 @@ CLI.prototype.login = function login(next) { }.bind(this), next: function (value, go2) { // try to login - appc.auth.login(argv.username, argv.password, function (result) { - if (result.error) { - logger.error(__('Login failed: %s', result.error.toString().replace(/\u001b\[\d+m/g, '').trim())); - // if they fail too many times, then just exit - if (++attempts > 3) { - logger.log(); - process.exit(1); + appc.auth.login({ + username: argv.username, + password: argv.password, + loginUrl: config.get('cli.auth.loginUrl'), + proxy: proxy, + callback: function (err, result) { + if (err) { + logger.error(__('Login failed: %s', err.toString().replace(/\u001b\[\d+m/g, '').trim())); + // if they fail too many times, then just exit + if (++attempts > 3) { + logger.log(); + process.exit(1); + } + go2('username'); + } else { + go2(); // done } - go2('username'); - } else { - go2(); // done } - }, proxy); + }); } }) }, { diff --git a/lib/commands/login.js b/lib/commands/login.js index 8fd7153c..5882c007 100644 --- a/lib/commands/login.js +++ b/lib/commands/login.js @@ -64,18 +64,24 @@ exports.config = function (logger, config, cli) { * @param {Function} finished - Callback when the command finishes */ exports.run = function (logger, config, cli, finished) { - appc.auth.login(cli.argv.username, cli.argv.password, function(result) { - if (result.error) { - if (result.error.type == 'AppcException') { - result.error.dump(logger.error); + appc.auth.login({ + username: cli.argv.username, + password: cli.argv.password, + loginUrl: config.get('cli.auth.loginUrl'), + proxy: config.get('cli.httpProxyServer'), + callback: function (err, result) { + if (err) { + if (err.type == 'AppcException') { + err.dump(logger.error); + } else { + logger.error(err.toString().trim()); + } + result && result.hasOwnProperty('loggedIn') && logger.error(result.loggedIn ? __('You are still logged in') : __('You are currently logged out')); } else { - logger.error(result.error.toString().trim()); + logger.log(__('Logged in successfully')); } - result.hasOwnProperty('loggedIn') && logger.error(result.loggedIn ? __('You are still logged in') : __('You are currently logged out')); - } else { - logger.log(__('Logged in successfully')); + logger.log(); + finished(); } - logger.log(); - finished(); - }, config.cli.httpProxyServer); + }); }; \ No newline at end of file diff --git a/lib/commands/logout.js b/lib/commands/logout.js index d8353bd5..6d3f391d 100644 --- a/lib/commands/logout.js +++ b/lib/commands/logout.js @@ -40,20 +40,24 @@ exports.config = function (logger, config, cli) { * @param {Function} finished - Callback when the command finishes */ exports.run = function (logger, config, cli, finished) { - appc.auth.logout(function (result) { - if (result.error) { - if (result.error.type == 'AppcException') { - result.error.dump(logger.error); + appc.auth.logout({ + logoutUrl: config.get('cli.auth.logoutUrl'), + proxy: config.get('cli.httpProxyServer'), + callback: function (err, result) { + if (err) { + if (err.type == 'AppcException') { + err.dump(logger.error); + } else { + logger.error(err.toString().trim()); + } + result && result.hasOwnProperty('loggedIn') && logger.error(result.loggedIn ? __('You are still logged in') : __('You are currently logged out')); + } else if (result.alreadyLoggedOut) { + logger.log(__('Already logged out')); } else { - logger.error(result.error.toString().trim()); + logger.log(__('Logged out successfully')); } - result.hasOwnProperty('loggedIn') && logger.error(result.loggedIn ? __('You are still logged in') : __('You are currently logged out')); - } else if (result.alreadyLoggedOut) { - logger.log(__('Already logged out')); - } else { - logger.log(__('Logged out successfully')); + logger.log(); + finished(); } - logger.log(); - finished(); - }, config.cli.httpProxyServer); + }); }; \ No newline at end of file diff --git a/lib/titanium.js b/lib/titanium.js index 8e012477..440a3c75 100644 --- a/lib/titanium.js +++ b/lib/titanium.js @@ -136,7 +136,7 @@ function run() { appId: pkginfo.about.id, appName: pkginfo.about.name, appGuid: 'cf5c67ed-1c3b-494b-afe0-01b958ef0f40', - directory: path.join('~', '.titanium'), + titaniumHomeDir: path.join('~', '.titanium'), version: pkginfo.version, deployType: 'production', httpProxyServer: config.cli.httpProxyServer,