aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.rs
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2023-03-19 21:52:54 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2023-03-19 21:52:54 +0100
commita1105320acfc8e48c707f2870ad2ba9ea7480bf4 (patch)
treec1de5822c8010191d1c327112fba7a3a2033d41e /src/api.rs
parent0509f3070dd66f5e770dd970f7def6878a57ddd8 (diff)
downloadrbw-a1105320acfc8e48c707f2870ad2ba9ea7480bf4.tar.gz
rbw-a1105320acfc8e48c707f2870ad2ba9ea7480bf4.zip
Add support for 2FA-method 'Email'.
Generalize the `two_factor` function to allow for different Providers. The `login` function now holds a list of supported providers that it tests in turn. The list should probably adhere to https://bitwarden.com/help/setup-two-step-login/#using-multiple-methods. Closes #90.
Diffstat (limited to 'src/api.rs')
-rw-r--r--src/api.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/api.rs b/src/api.rs
index 174949d..f2c853d 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -57,6 +57,31 @@ pub enum TwoFactorProviderType {
WebAuthn = 7,
}
+impl TwoFactorProviderType {
+ pub fn message(&self) -> &str {
+ match *self {
+ TwoFactorProviderType::Authenticator => "Enter the 6 digit verification code from your authenticator app.",
+ TwoFactorProviderType::Email => "Enter the PIN you received via email.",
+ _ => "Enter the code."
+ }
+ }
+
+ pub fn header(&self) -> &str {
+ match *self {
+ TwoFactorProviderType::Authenticator => "Authenticator App",
+ TwoFactorProviderType::Email => "Email Code",
+ _ => "Two Factor Authentication"
+ }
+ }
+
+ pub fn grab(&self) -> bool {
+ match *self {
+ TwoFactorProviderType::Email => false,
+ _ => true
+ }
+ }
+}
+
impl<'de> serde::Deserialize<'de> for TwoFactorProviderType {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where