From d26f48a5d3fbe94cc79fab8e54c1fd0be6c1ac00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Ignacio=20Torres?= Date: Wed, 21 Jan 2026 14:39:21 -0800 Subject: [PATCH 1/2] Record username in 2FA token --- src/app.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index c0fa406..6e6fe9a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -872,7 +872,7 @@ impl InviteCodeManager { 30, Secret::Encoded(res.0).to_bytes().unwrap(), Some("Northsky".to_string()), - "Northsky".to_string(), + self.username.clone(), ) .unwrap(); let qr_code = totp.get_qr_png().unwrap(); @@ -1246,3 +1246,28 @@ struct LoginRequest { pub username: String, pub password: String, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_totp_uses_username_as_account_name() { + let test_username = "testuser@example.com"; + let test_secret = "JBSWY3DPEHPK3PXP"; + + let totp = TOTP::new( + Algorithm::SHA1, + 6, + 1, + 30, + Secret::Raw(test_secret.as_bytes().to_vec()).to_bytes().unwrap(), + Some("Northsky".to_string()), + test_username.to_string(), + ) + .unwrap(); + + assert_eq!(totp.account_name, test_username); + assert_eq!(totp.issuer, Some("Northsky".to_string())); + } +} From 5bd20618bba020f51faa886708ac0691bb8c49ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Ignacio=20Torres?= Date: Wed, 21 Jan 2026 15:30:00 -0800 Subject: [PATCH 2/2] style: fmt changes --- src/app.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 6e6fe9a..905369a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1261,7 +1261,9 @@ mod tests { 6, 1, 30, - Secret::Raw(test_secret.as_bytes().to_vec()).to_bytes().unwrap(), + Secret::Raw(test_secret.as_bytes().to_vec()) + .to_bytes() + .unwrap(), Some("Northsky".to_string()), test_username.to_string(), )