mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Print login failed error message once instead of twice
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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."
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user