From 4845bcb3ea7e5b9f506e909f12efd3023a8dfb0e Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 6 Dec 2020 06:08:54 +0100 Subject: [PATCH] it's actually totp not otp --- migrations/2019-09-02-123920_create_providers/up.sql | 2 +- src/models/algorithm.rs | 12 ++++++------ src/models/provider.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/migrations/2019-09-02-123920_create_providers/up.sql b/migrations/2019-09-02-123920_create_providers/up.sql index 2a83fcb..4775df9 100644 --- a/migrations/2019-09-02-123920_create_providers/up.sql +++ b/migrations/2019-09-02-123920_create_providers/up.sql @@ -6,5 +6,5 @@ CREATE TABLE "providers" ( "help_url" VARCHAR NULL, "image_uri" VARCHAR NULL, "period" INTEGER NULL DEFAULT 30, - "algorithm" VARCHAR DEFAULT "OTP" + "algorithm" VARCHAR DEFAULT "TOTP" ); diff --git a/src/models/algorithm.rs b/src/models/algorithm.rs index 81d8621..ada46d9 100644 --- a/src/models/algorithm.rs +++ b/src/models/algorithm.rs @@ -6,8 +6,8 @@ use std::string::ToString; #[repr(u32)] #[genum(type_name = "ProviderAlgorithm")] pub enum Algorithm { - #[genum(name = "OTP")] - OTP = 0, + #[genum(name = "TOTP")] + TOTP = 0, #[genum(name = "HOTP")] HOTP = 1, Steam = 2, @@ -16,8 +16,8 @@ pub enum Algorithm { impl Algorithm { pub fn to_locale_string(&self) -> String { match *self { - Algorithm::HOTP => gettext("HOTP"), - Algorithm::OTP => gettext("One-Time-Password"), + Algorithm::HOTP => gettext("HMAC-based One-time Password"), + Algorithm::TOTP => gettext("Time-based One-Time-Password"), Algorithm::Steam => gettext("Steam"), } } @@ -27,7 +27,7 @@ impl FromStr for Algorithm { type Err = anyhow::Error; fn from_str(s: &str) -> Result { match s.to_lowercase().as_ref() { - "otp" => Ok(Self::OTP), + "totp" | "otp" => Ok(Self::TOTP), "hotp" => Ok(Self::HOTP), "steam" => Ok(Self::Steam), _ => anyhow::bail!("Unsupported algorithm"), @@ -38,7 +38,7 @@ impl FromStr for Algorithm { impl ToString for Algorithm { fn to_string(&self) -> String { match *self { - Algorithm::OTP => "otp", + Algorithm::TOTP => "totp", Algorithm::HOTP => "hotp", Algorithm::Steam => "steam", } diff --git a/src/models/provider.rs b/src/models/provider.rs index 792e54e..3e4d4f2 100644 --- a/src/models/provider.rs +++ b/src/models/provider.rs @@ -90,7 +90,7 @@ static PROPERTIES: [subclass::Property; 8] = [ name, "algorithm", "Algorithm", - Some(&Algorithm::OTP.to_string()), + Some(&Algorithm::TOTP.to_string()), glib::ParamFlags::READWRITE, ) }), @@ -144,7 +144,7 @@ impl ObjectSubclass for ProviderPriv { website: RefCell::new(None), help_url: RefCell::new(None), image_uri: RefCell::new(None), - algorithm: RefCell::new(Algorithm::OTP.to_string()), + algorithm: RefCell::new(Algorithm::TOTP.to_string()), period: Cell::new(30), filter_model: gtk::FilterListModel::new(Some(&model), gtk::NONE_FILTER), accounts: model,