mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-10 18:55:57 +03:00
Make sure TOTP codes can be both Numbers or Strings, fixes #30
This commit is contained in:
@@ -22,7 +22,7 @@ struct PasswordData {
|
||||
masterPasswordHash: String
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(untagged)]
|
||||
enum NumberOrString {
|
||||
Number(i32),
|
||||
@@ -36,4 +36,11 @@ impl NumberOrString {
|
||||
NumberOrString::String(s) => s
|
||||
}
|
||||
}
|
||||
|
||||
fn to_i32(self) -> Option<i32> {
|
||||
match self {
|
||||
NumberOrString::Number(n) => Some(n),
|
||||
NumberOrString::String(s) => s.parse().ok()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user