mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 19:22:33 +00:00
Also check the token argument
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
parent
b3da66f65b
commit
ff575b290f
|
@ -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) = ®_cfg {
|
||||
if old_token == &token {
|
||||
config.shell().status("Login", "already logged in")?;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue