diff --git a/tools/auth.js b/tools/auth.js index f3287582a9..1b0a876782 100644 --- a/tools/auth.js +++ b/tools/auth.js @@ -434,6 +434,8 @@ var logInToGalaxy = function (galaxyName) { // include: // - retry: if true, then if the user gets the password wrong, // reprompt. +// - suppressErrorMessage: true if the function should not print an +// error message to stderr if the login fails var doInteractivePasswordLogin = function (options) { var loginData = {}; @@ -445,7 +447,9 @@ var doInteractivePasswordLogin = function (options) { throw new Error("Need username or email"); var loginFailed = function () { - process.stderr.write("Login failed.\n"); + if (! options.suppressErrorMessage) { + process.stderr.write("Login failed.\n"); + } }; var conn = authConn(); @@ -493,6 +497,8 @@ var doInteractivePasswordLogin = function (options) { return true; }; +exports.doInteractivePasswordLogin = doInteractivePasswordLogin; + exports.loginCommand = function (options) { config.printUniverseBanner(); diff --git a/tools/deploy.js b/tools/deploy.js index 6398684552..ff4f314c8a 100644 --- a/tools/deploy.js +++ b/tools/deploy.js @@ -153,13 +153,18 @@ var authedRpc = function (options) { if (infoResult.statusCode === 403 && rpcOptions.promptIfAuthFails) { // Our authentication didn't validate, so prompt the user to log in // again, and resend the RPC if the login succeeds. - var loginResult = auth.loginCommand(_.extend({}, rpcOptions, { - overwriteExistingToken: true - })); - if (loginResult === 0) { - // If the login prompt succeeded, then resend the RPC with the - // original options. + var username = utils.readLine({ prompt: "Username: " }); + var loginOptions = { + username: username, + suppressErrorMessage: true + }; + if (auth.doInteractivePasswordLogin(loginOptions)) { return authedRpc(options); + } else { + return { + statusCode: 403, + errorMessage: "login failed." + }; } }