Also check the token argument

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
hi-rustin 2022-09-26 23:27:18 +08:00 committed by 二手掉包工程师
parent b3da66f65b
commit ff575b290f
2 changed files with 16 additions and 6 deletions

View file

@ -764,14 +764,14 @@ pub fn registry_login(
.with_context(|| "failed to read stdin")?;
// Automatically remove `cargo login` from an inputted token to
// allow direct pastes from `registry.host()`/me.
line = line.replace("cargo login", "").trim().to_string();
if line.is_empty() {
bail!("please provide a non-empty token");
}
line
line.replace("cargo login", "").trim().to_string()
}
};
if token.is_empty() {
bail!("please provide a non-empty token");
}
if let RegistryConfig::Token(old_token) = &reg_cfg {
if old_token == &token {
config.shell().status("Login", "already logged in")?;

View file

@ -106,5 +106,15 @@ fn empty_login_token() {
",
)
.with_status(101)
.run()
.run();
cargo_process("login")
.arg("")
.with_stderr(
"\
[ERROR] please provide a non-empty token
",
)
.with_status(101)
.run();
}