Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1738,24 +1738,20 @@ fn classify_login_error(error_res: &ConnectErrorRes, code: u16) -> Error {
"invalid_client" => {
return Error::IncorrectApiKey;
}
"" => {
// bitwarden_rs returns an empty error and error_description for
// this case, for some reason
if error_desc.is_none() || error_desc == Some("") {
if let Some(error_model) = error_res.error_model.as_ref() {
let message = error_model.message.as_str().to_string();
match message.as_str() {
"Username or password is incorrect. Try again"
| "TOTP code is not a number" => {
// bitwarden_rs returns an empty error and error_description for
// this case, for some reason
"" if error_desc.is_none() || error_desc == Some("") => {
if let Some(error_model) = error_res.error_model.as_ref() {
let message = error_model.message.as_str().to_string();
match message.as_str() {
"Username or password is incorrect. Try again"
| "TOTP code is not a number" => {
return Error::IncorrectPassword { message };
}
s => {
if s.starts_with("Invalid TOTP code! Server time: ") {
return Error::IncorrectPassword { message };
}
s => {
if s.starts_with(
"Invalid TOTP code! Server time: ",
) {
return Error::IncorrectPassword { message };
}
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/bin/rbw/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1507,8 +1507,7 @@ pub fn search(
.filter(|entry| {
entry
.as_ref()
.map(|entry| entry.search_match(term, folder))
.unwrap_or(true)
.map_or(true, |entry| entry.search_match(term, folder))
})
.map(|entry| entry.map(std::convert::Into::into))
.collect::<Result<_, anyhow::Error>>()?;
Expand Down
Loading