fix using uppercase letters in username during setup causing panic
fixes #171
This commit is contained in:
parent
738e8f1664
commit
cae60f6ed6
2 changed files with 15 additions and 1 deletions
|
@ -318,6 +318,12 @@ impl Manifest {
|
||||||
self.entries.iter().any(|e| e.account_name.is_empty())
|
self.entries.iter().any(|e| e.account_name.is_empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn has_any_uppercase_in_account_names(&self) -> bool {
|
||||||
|
self.entries
|
||||||
|
.iter()
|
||||||
|
.any(|e| e.account_name != e.account_name.to_lowercase())
|
||||||
|
}
|
||||||
|
|
||||||
/// Performs auto-upgrades on the manifest. Returns true if any upgrades were performed.
|
/// Performs auto-upgrades on the manifest. Returns true if any upgrades were performed.
|
||||||
pub fn auto_upgrade(&mut self) -> anyhow::Result<bool, ManifestAccountLoadError> {
|
pub fn auto_upgrade(&mut self) -> anyhow::Result<bool, ManifestAccountLoadError> {
|
||||||
debug!("Performing auto-upgrade...");
|
debug!("Performing auto-upgrade...");
|
||||||
|
@ -331,6 +337,14 @@ impl Manifest {
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.has_any_uppercase_in_account_names() {
|
||||||
|
debug!("Lowercasing account names");
|
||||||
|
for i in 0..self.entries.len() {
|
||||||
|
self.entries[i].account_name = self.entries[i].account_name.to_lowercase();
|
||||||
|
}
|
||||||
|
upgraded = true;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(upgraded)
|
Ok(upgraded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,7 @@ fn do_subcmd_setup(
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
println!("Log in to the account that you want to link to steamguard-cli");
|
println!("Log in to the account that you want to link to steamguard-cli");
|
||||||
print!("Username: ");
|
print!("Username: ");
|
||||||
let username = tui::prompt();
|
let username = tui::prompt().to_lowercase();
|
||||||
let account_name = username.clone();
|
let account_name = username.clone();
|
||||||
if manifest.account_exists(&username) {
|
if manifest.account_exists(&username) {
|
||||||
bail!(
|
bail!(
|
||||||
|
|
Loading…
Reference in a new issue