diff --git a/src/accountmanager.rs b/src/accountmanager.rs index 9726454..88c37ab 100644 --- a/src/accountmanager.rs +++ b/src/accountmanager.rs @@ -318,6 +318,12 @@ impl Manifest { 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. pub fn auto_upgrade(&mut self) -> anyhow::Result { debug!("Performing auto-upgrade..."); @@ -331,6 +337,14 @@ impl Manifest { 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) } } diff --git a/src/main.rs b/src/main.rs index 68e7fb7..3056a9b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -354,7 +354,7 @@ fn do_subcmd_setup( ) -> anyhow::Result<()> { println!("Log in to the account that you want to link to steamguard-cli"); print!("Username: "); - let username = tui::prompt(); + let username = tui::prompt().to_lowercase(); let account_name = username.clone(); if manifest.account_exists(&username) { bail!(